$search
00001 00007 package org.best_of_robotics.model.datatypes.impl; 00008 00009 import org.best_of_robotics.model.datatypes.DatatypesPackage; 00010 import org.best_of_robotics.model.datatypes.SimpleType; 00011 00012 import org.best_of_robotics.model.datatypes.TypesLibrary; 00013 import org.eclipse.emf.common.notify.Notification; 00014 00015 import org.eclipse.emf.common.notify.NotificationChain; 00016 import org.eclipse.emf.ecore.EClass; 00017 00018 import org.eclipse.emf.ecore.InternalEObject; 00019 import org.eclipse.emf.ecore.impl.ENotificationImpl; 00020 import org.eclipse.emf.ecore.impl.EObjectImpl; 00021 import org.eclipse.emf.ecore.util.EcoreUtil; 00022 00037 public class SimpleTypeImpl extends EObjectImpl implements SimpleType { 00046 protected static final String NAME_EDEFAULT = null; 00047 00056 protected String name = NAME_EDEFAULT; 00057 00063 protected SimpleTypeImpl() { 00064 super(); 00065 } 00066 00072 @Override 00073 protected EClass eStaticClass() { 00074 return DatatypesPackage.Literals.SIMPLE_TYPE; 00075 } 00076 00082 public String getName() { 00083 return name; 00084 } 00085 00091 public void setName(String newName) { 00092 String oldName = name; 00093 name = newName; 00094 if (eNotificationRequired()) 00095 eNotify(new ENotificationImpl(this, Notification.SET, DatatypesPackage.SIMPLE_TYPE__NAME, oldName, name)); 00096 } 00097 00103 public TypesLibrary getTypesLibrary() { 00104 if (eContainerFeatureID() != DatatypesPackage.SIMPLE_TYPE__TYPES_LIBRARY) return null; 00105 return (TypesLibrary)eContainer(); 00106 } 00107 00113 public NotificationChain basicSetTypesLibrary(TypesLibrary newTypesLibrary, NotificationChain msgs) { 00114 msgs = eBasicSetContainer((InternalEObject)newTypesLibrary, DatatypesPackage.SIMPLE_TYPE__TYPES_LIBRARY, msgs); 00115 return msgs; 00116 } 00117 00123 public void setTypesLibrary(TypesLibrary newTypesLibrary) { 00124 if (newTypesLibrary != eInternalContainer() || (eContainerFeatureID() != DatatypesPackage.SIMPLE_TYPE__TYPES_LIBRARY && newTypesLibrary != null)) { 00125 if (EcoreUtil.isAncestor(this, newTypesLibrary)) 00126 throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); 00127 NotificationChain msgs = null; 00128 if (eInternalContainer() != null) 00129 msgs = eBasicRemoveFromContainer(msgs); 00130 if (newTypesLibrary != null) 00131 msgs = ((InternalEObject)newTypesLibrary).eInverseAdd(this, DatatypesPackage.TYPES_LIBRARY__TYPES, TypesLibrary.class, msgs); 00132 msgs = basicSetTypesLibrary(newTypesLibrary, msgs); 00133 if (msgs != null) msgs.dispatch(); 00134 } 00135 else if (eNotificationRequired()) 00136 eNotify(new ENotificationImpl(this, Notification.SET, DatatypesPackage.SIMPLE_TYPE__TYPES_LIBRARY, newTypesLibrary, newTypesLibrary)); 00137 } 00138 00144 @Override 00145 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { 00146 switch (featureID) { 00147 case DatatypesPackage.SIMPLE_TYPE__TYPES_LIBRARY: 00148 if (eInternalContainer() != null) 00149 msgs = eBasicRemoveFromContainer(msgs); 00150 return basicSetTypesLibrary((TypesLibrary)otherEnd, msgs); 00151 } 00152 return super.eInverseAdd(otherEnd, featureID, msgs); 00153 } 00154 00160 @Override 00161 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { 00162 switch (featureID) { 00163 case DatatypesPackage.SIMPLE_TYPE__TYPES_LIBRARY: 00164 return basicSetTypesLibrary(null, msgs); 00165 } 00166 return super.eInverseRemove(otherEnd, featureID, msgs); 00167 } 00168 00174 @Override 00175 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { 00176 switch (eContainerFeatureID()) { 00177 case DatatypesPackage.SIMPLE_TYPE__TYPES_LIBRARY: 00178 return eInternalContainer().eInverseRemove(this, DatatypesPackage.TYPES_LIBRARY__TYPES, TypesLibrary.class, msgs); 00179 } 00180 return super.eBasicRemoveFromContainerFeature(msgs); 00181 } 00182 00188 @Override 00189 public Object eGet(int featureID, boolean resolve, boolean coreType) { 00190 switch (featureID) { 00191 case DatatypesPackage.SIMPLE_TYPE__NAME: 00192 return getName(); 00193 case DatatypesPackage.SIMPLE_TYPE__TYPES_LIBRARY: 00194 return getTypesLibrary(); 00195 } 00196 return super.eGet(featureID, resolve, coreType); 00197 } 00198 00204 @Override 00205 public void eSet(int featureID, Object newValue) { 00206 switch (featureID) { 00207 case DatatypesPackage.SIMPLE_TYPE__NAME: 00208 setName((String)newValue); 00209 return; 00210 case DatatypesPackage.SIMPLE_TYPE__TYPES_LIBRARY: 00211 setTypesLibrary((TypesLibrary)newValue); 00212 return; 00213 } 00214 super.eSet(featureID, newValue); 00215 } 00216 00222 @Override 00223 public void eUnset(int featureID) { 00224 switch (featureID) { 00225 case DatatypesPackage.SIMPLE_TYPE__NAME: 00226 setName(NAME_EDEFAULT); 00227 return; 00228 case DatatypesPackage.SIMPLE_TYPE__TYPES_LIBRARY: 00229 setTypesLibrary((TypesLibrary)null); 00230 return; 00231 } 00232 super.eUnset(featureID); 00233 } 00234 00240 @Override 00241 public boolean eIsSet(int featureID) { 00242 switch (featureID) { 00243 case DatatypesPackage.SIMPLE_TYPE__NAME: 00244 return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); 00245 case DatatypesPackage.SIMPLE_TYPE__TYPES_LIBRARY: 00246 return getTypesLibrary() != null; 00247 } 00248 return super.eIsSet(featureID); 00249 } 00250 00256 @Override 00257 public String toString() { 00258 if (eIsProxy()) return super.toString(); 00259 00260 StringBuffer result = new StringBuffer(super.toString()); 00261 result.append(" (name: "); 00262 result.append(name); 00263 result.append(')'); 00264 return result.toString(); 00265 } 00266 00267 } //SimpleTypeImpl