$search
00001 00007 package org.best_of_robotics.model.datatypes.impl; 00008 00009 import java.lang.String; 00010 00011 import java.util.Collection; 00012 00013 import org.best_of_robotics.model.datatypes.CustomType; 00014 import org.best_of_robotics.model.datatypes.DatatypesPackage; 00015 import org.best_of_robotics.model.datatypes.Field; 00016 00017 import org.best_of_robotics.model.datatypes.TypesLibrary; 00018 import org.eclipse.emf.common.notify.Notification; 00019 import org.eclipse.emf.common.notify.NotificationChain; 00020 00021 import org.eclipse.emf.common.util.EList; 00022 00023 import org.eclipse.emf.ecore.EClass; 00024 import org.eclipse.emf.ecore.InternalEObject; 00025 00026 import org.eclipse.emf.ecore.impl.ENotificationImpl; 00027 import org.eclipse.emf.ecore.impl.EObjectImpl; 00028 00029 import org.eclipse.emf.ecore.util.EObjectContainmentEList; 00030 import org.eclipse.emf.ecore.util.EcoreUtil; 00031 import org.eclipse.emf.ecore.util.InternalEList; 00032 00048 public class CustomTypeImpl extends EObjectImpl implements CustomType { 00057 protected static final String NAME_EDEFAULT = null; 00058 00067 protected String name = NAME_EDEFAULT; 00068 00077 protected EList<Field> fields; 00078 00084 protected CustomTypeImpl() { 00085 super(); 00086 } 00087 00093 @Override 00094 protected EClass eStaticClass() { 00095 return DatatypesPackage.Literals.CUSTOM_TYPE; 00096 } 00097 00103 public String getName() { 00104 return name; 00105 } 00106 00112 public void setName(String newName) { 00113 String oldName = name; 00114 name = newName; 00115 if (eNotificationRequired()) 00116 eNotify(new ENotificationImpl(this, Notification.SET, DatatypesPackage.CUSTOM_TYPE__NAME, oldName, name)); 00117 } 00118 00124 public TypesLibrary getTypesLibrary() { 00125 if (eContainerFeatureID() != DatatypesPackage.CUSTOM_TYPE__TYPES_LIBRARY) return null; 00126 return (TypesLibrary)eContainer(); 00127 } 00128 00134 public NotificationChain basicSetTypesLibrary(TypesLibrary newTypesLibrary, NotificationChain msgs) { 00135 msgs = eBasicSetContainer((InternalEObject)newTypesLibrary, DatatypesPackage.CUSTOM_TYPE__TYPES_LIBRARY, msgs); 00136 return msgs; 00137 } 00138 00144 public void setTypesLibrary(TypesLibrary newTypesLibrary) { 00145 if (newTypesLibrary != eInternalContainer() || (eContainerFeatureID() != DatatypesPackage.CUSTOM_TYPE__TYPES_LIBRARY && newTypesLibrary != null)) { 00146 if (EcoreUtil.isAncestor(this, newTypesLibrary)) 00147 throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); 00148 NotificationChain msgs = null; 00149 if (eInternalContainer() != null) 00150 msgs = eBasicRemoveFromContainer(msgs); 00151 if (newTypesLibrary != null) 00152 msgs = ((InternalEObject)newTypesLibrary).eInverseAdd(this, DatatypesPackage.TYPES_LIBRARY__TYPES, TypesLibrary.class, msgs); 00153 msgs = basicSetTypesLibrary(newTypesLibrary, msgs); 00154 if (msgs != null) msgs.dispatch(); 00155 } 00156 else if (eNotificationRequired()) 00157 eNotify(new ENotificationImpl(this, Notification.SET, DatatypesPackage.CUSTOM_TYPE__TYPES_LIBRARY, newTypesLibrary, newTypesLibrary)); 00158 } 00159 00165 public EList<Field> getFields() { 00166 if (fields == null) { 00167 fields = new EObjectContainmentEList<Field>(Field.class, this, DatatypesPackage.CUSTOM_TYPE__FIELDS); 00168 } 00169 return fields; 00170 } 00171 00177 public String getLabel(){ 00178 String label = name; 00179 // if( namespace != null && namespace.length()>0 ) 00180 // label = namespace + "::" + label; 00181 return label; 00182 } 00183 00189 @Override 00190 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { 00191 switch (featureID) { 00192 case DatatypesPackage.CUSTOM_TYPE__TYPES_LIBRARY: 00193 if (eInternalContainer() != null) 00194 msgs = eBasicRemoveFromContainer(msgs); 00195 return basicSetTypesLibrary((TypesLibrary)otherEnd, msgs); 00196 } 00197 return super.eInverseAdd(otherEnd, featureID, msgs); 00198 } 00199 00205 @Override 00206 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { 00207 switch (featureID) { 00208 case DatatypesPackage.CUSTOM_TYPE__TYPES_LIBRARY: 00209 return basicSetTypesLibrary(null, msgs); 00210 case DatatypesPackage.CUSTOM_TYPE__FIELDS: 00211 return ((InternalEList<?>)getFields()).basicRemove(otherEnd, msgs); 00212 } 00213 return super.eInverseRemove(otherEnd, featureID, msgs); 00214 } 00215 00221 @Override 00222 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { 00223 switch (eContainerFeatureID()) { 00224 case DatatypesPackage.CUSTOM_TYPE__TYPES_LIBRARY: 00225 return eInternalContainer().eInverseRemove(this, DatatypesPackage.TYPES_LIBRARY__TYPES, TypesLibrary.class, msgs); 00226 } 00227 return super.eBasicRemoveFromContainerFeature(msgs); 00228 } 00229 00235 @Override 00236 public Object eGet(int featureID, boolean resolve, boolean coreType) { 00237 switch (featureID) { 00238 case DatatypesPackage.CUSTOM_TYPE__NAME: 00239 return getName(); 00240 case DatatypesPackage.CUSTOM_TYPE__TYPES_LIBRARY: 00241 return getTypesLibrary(); 00242 case DatatypesPackage.CUSTOM_TYPE__FIELDS: 00243 return getFields(); 00244 } 00245 return super.eGet(featureID, resolve, coreType); 00246 } 00247 00253 @SuppressWarnings("unchecked") 00254 @Override 00255 public void eSet(int featureID, Object newValue) { 00256 switch (featureID) { 00257 case DatatypesPackage.CUSTOM_TYPE__NAME: 00258 setName((String)newValue); 00259 return; 00260 case DatatypesPackage.CUSTOM_TYPE__TYPES_LIBRARY: 00261 setTypesLibrary((TypesLibrary)newValue); 00262 return; 00263 case DatatypesPackage.CUSTOM_TYPE__FIELDS: 00264 getFields().clear(); 00265 getFields().addAll((Collection<? extends Field>)newValue); 00266 return; 00267 } 00268 super.eSet(featureID, newValue); 00269 } 00270 00276 @Override 00277 public void eUnset(int featureID) { 00278 switch (featureID) { 00279 case DatatypesPackage.CUSTOM_TYPE__NAME: 00280 setName(NAME_EDEFAULT); 00281 return; 00282 case DatatypesPackage.CUSTOM_TYPE__TYPES_LIBRARY: 00283 setTypesLibrary((TypesLibrary)null); 00284 return; 00285 case DatatypesPackage.CUSTOM_TYPE__FIELDS: 00286 getFields().clear(); 00287 return; 00288 } 00289 super.eUnset(featureID); 00290 } 00291 00297 @Override 00298 public boolean eIsSet(int featureID) { 00299 switch (featureID) { 00300 case DatatypesPackage.CUSTOM_TYPE__NAME: 00301 return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); 00302 case DatatypesPackage.CUSTOM_TYPE__TYPES_LIBRARY: 00303 return getTypesLibrary() != null; 00304 case DatatypesPackage.CUSTOM_TYPE__FIELDS: 00305 return fields != null && !fields.isEmpty(); 00306 } 00307 return super.eIsSet(featureID); 00308 } 00309 00315 @Override 00316 public String toString() { 00317 if (eIsProxy()) return super.toString(); 00318 00319 StringBuffer result = new StringBuffer(super.toString()); 00320 result.append(" (name: "); 00321 result.append(name); 00322 result.append(')'); 00323 return result.toString(); 00324 } 00325 00326 } //CustomTypeImpl