VectorTypeImpl.java
Go to the documentation of this file.
00001 
00007 package org.best_of_robotics.model.datatypes.impl;
00008 
00009 import java.lang.String;
00010 
00011 import org.best_of_robotics.model.datatypes.ComplexType;
00012 import org.best_of_robotics.model.datatypes.DataType;
00013 import org.best_of_robotics.model.datatypes.DatatypesPackage;
00014 import org.best_of_robotics.model.datatypes.TypesLibrary;
00015 import org.best_of_robotics.model.datatypes.SimpleType;
00016 import org.best_of_robotics.model.datatypes.VectorType;
00017 
00018 import org.eclipse.emf.common.notify.Notification;
00019 
00020 import org.eclipse.emf.common.notify.NotificationChain;
00021 import org.eclipse.emf.ecore.EClass;
00022 import org.eclipse.emf.ecore.InternalEObject;
00023 
00024 import org.eclipse.emf.ecore.impl.ENotificationImpl;
00025 import org.eclipse.emf.ecore.impl.EObjectImpl;
00026 import org.eclipse.emf.ecore.util.EcoreUtil;
00027 
00043 public class VectorTypeImpl extends EObjectImpl implements VectorType {
00052         protected static final String NAME_EDEFAULT = null;
00053 
00062         protected String name = NAME_EDEFAULT;
00063 
00072         protected DataType template;
00073 
00079         protected VectorTypeImpl() {
00080                 super();
00081         }
00082 
00088         @Override
00089         protected EClass eStaticClass() {
00090                 return DatatypesPackage.Literals.VECTOR_TYPE;
00091         }
00092 
00098         public String getName() {
00099                 return name;
00100         }
00101 
00107         public void setName(String newName) {
00108                 String oldName = name;
00109                 name = newName;
00110                 if (eNotificationRequired())
00111                         eNotify(new ENotificationImpl(this, Notification.SET, DatatypesPackage.VECTOR_TYPE__NAME, oldName, name));
00112         }
00113 
00119         public TypesLibrary getTypesLibrary() {
00120                 if (eContainerFeatureID() != DatatypesPackage.VECTOR_TYPE__TYPES_LIBRARY) return null;
00121                 return (TypesLibrary)eContainer();
00122         }
00123 
00129         public NotificationChain basicSetTypesLibrary(TypesLibrary newTypesLibrary, NotificationChain msgs) {
00130                 msgs = eBasicSetContainer((InternalEObject)newTypesLibrary, DatatypesPackage.VECTOR_TYPE__TYPES_LIBRARY, msgs);
00131                 return msgs;
00132         }
00133 
00139         public void setTypesLibrary(TypesLibrary newTypesLibrary) {
00140                 if (newTypesLibrary != eInternalContainer() || (eContainerFeatureID() != DatatypesPackage.VECTOR_TYPE__TYPES_LIBRARY && newTypesLibrary != null)) {
00141                         if (EcoreUtil.isAncestor(this, newTypesLibrary))
00142                                 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
00143                         NotificationChain msgs = null;
00144                         if (eInternalContainer() != null)
00145                                 msgs = eBasicRemoveFromContainer(msgs);
00146                         if (newTypesLibrary != null)
00147                                 msgs = ((InternalEObject)newTypesLibrary).eInverseAdd(this, DatatypesPackage.TYPES_LIBRARY__TYPES, TypesLibrary.class, msgs);
00148                         msgs = basicSetTypesLibrary(newTypesLibrary, msgs);
00149                         if (msgs != null) msgs.dispatch();
00150                 }
00151                 else if (eNotificationRequired())
00152                         eNotify(new ENotificationImpl(this, Notification.SET, DatatypesPackage.VECTOR_TYPE__TYPES_LIBRARY, newTypesLibrary, newTypesLibrary));
00153         }
00154 
00160         public DataType getTemplate() {
00161                 if (template != null && template.eIsProxy()) {
00162                         InternalEObject oldTemplate = (InternalEObject)template;
00163                         template = (DataType)eResolveProxy(oldTemplate);
00164                         if (template != oldTemplate) {
00165                                 if (eNotificationRequired())
00166                                         eNotify(new ENotificationImpl(this, Notification.RESOLVE, DatatypesPackage.VECTOR_TYPE__TEMPLATE, oldTemplate, template));
00167                         }
00168                 }
00169                 return template;
00170         }
00171 
00177         public DataType basicGetTemplate() {
00178                 return template;
00179         }
00180 
00186         public void setTemplate(DataType newTemplate) {
00187                 DataType oldTemplate = template;
00188                 template = newTemplate;
00189                 if (eNotificationRequired())
00190                         eNotify(new ENotificationImpl(this, Notification.SET, DatatypesPackage.VECTOR_TYPE__TEMPLATE, oldTemplate, template));
00191         }
00192 
00198         public String getLabel(){
00199                 String label = name;
00200                 if(template instanceof ComplexType){
00201                         label += "<" + ((ComplexType)template).getLabel() + ">";
00202                 }else if (template instanceof SimpleType){
00203                         label += "<" + template.getName() + ">";
00204                 }
00205                 return "std::" + label;
00206         }
00207 
00213         @Override
00214         public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
00215                 switch (featureID) {
00216                         case DatatypesPackage.VECTOR_TYPE__TYPES_LIBRARY:
00217                                 if (eInternalContainer() != null)
00218                                         msgs = eBasicRemoveFromContainer(msgs);
00219                                 return basicSetTypesLibrary((TypesLibrary)otherEnd, msgs);
00220                 }
00221                 return super.eInverseAdd(otherEnd, featureID, msgs);
00222         }
00223 
00229         @Override
00230         public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
00231                 switch (featureID) {
00232                         case DatatypesPackage.VECTOR_TYPE__TYPES_LIBRARY:
00233                                 return basicSetTypesLibrary(null, msgs);
00234                 }
00235                 return super.eInverseRemove(otherEnd, featureID, msgs);
00236         }
00237 
00243         @Override
00244         public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
00245                 switch (eContainerFeatureID()) {
00246                         case DatatypesPackage.VECTOR_TYPE__TYPES_LIBRARY:
00247                                 return eInternalContainer().eInverseRemove(this, DatatypesPackage.TYPES_LIBRARY__TYPES, TypesLibrary.class, msgs);
00248                 }
00249                 return super.eBasicRemoveFromContainerFeature(msgs);
00250         }
00251 
00257         @Override
00258         public Object eGet(int featureID, boolean resolve, boolean coreType) {
00259                 switch (featureID) {
00260                         case DatatypesPackage.VECTOR_TYPE__NAME:
00261                                 return getName();
00262                         case DatatypesPackage.VECTOR_TYPE__TYPES_LIBRARY:
00263                                 return getTypesLibrary();
00264                         case DatatypesPackage.VECTOR_TYPE__TEMPLATE:
00265                                 if (resolve) return getTemplate();
00266                                 return basicGetTemplate();
00267                 }
00268                 return super.eGet(featureID, resolve, coreType);
00269         }
00270 
00276         @Override
00277         public void eSet(int featureID, Object newValue) {
00278                 switch (featureID) {
00279                         case DatatypesPackage.VECTOR_TYPE__NAME:
00280                                 setName((String)newValue);
00281                                 return;
00282                         case DatatypesPackage.VECTOR_TYPE__TYPES_LIBRARY:
00283                                 setTypesLibrary((TypesLibrary)newValue);
00284                                 return;
00285                         case DatatypesPackage.VECTOR_TYPE__TEMPLATE:
00286                                 setTemplate((DataType)newValue);
00287                                 return;
00288                 }
00289                 super.eSet(featureID, newValue);
00290         }
00291 
00297         @Override
00298         public void eUnset(int featureID) {
00299                 switch (featureID) {
00300                         case DatatypesPackage.VECTOR_TYPE__NAME:
00301                                 setName(NAME_EDEFAULT);
00302                                 return;
00303                         case DatatypesPackage.VECTOR_TYPE__TYPES_LIBRARY:
00304                                 setTypesLibrary((TypesLibrary)null);
00305                                 return;
00306                         case DatatypesPackage.VECTOR_TYPE__TEMPLATE:
00307                                 setTemplate((DataType)null);
00308                                 return;
00309                 }
00310                 super.eUnset(featureID);
00311         }
00312 
00318         @Override
00319         public boolean eIsSet(int featureID) {
00320                 switch (featureID) {
00321                         case DatatypesPackage.VECTOR_TYPE__NAME:
00322                                 return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
00323                         case DatatypesPackage.VECTOR_TYPE__TYPES_LIBRARY:
00324                                 return getTypesLibrary() != null;
00325                         case DatatypesPackage.VECTOR_TYPE__TEMPLATE:
00326                                 return template != null;
00327                 }
00328                 return super.eIsSet(featureID);
00329         }
00330 
00336         @Override
00337         public String toString() {
00338                 if (eIsProxy()) return super.toString();
00339 
00340                 StringBuffer result = new StringBuffer(super.toString());
00341                 result.append(" (name: ");
00342                 result.append(name);
00343                 result.append(')');
00344                 return result.toString();
00345         }
00346 
00347 } //VectorTypeImpl


bride_plugin_source
Author(s): Alexander Bubeck
autogenerated on Sun Oct 5 2014 22:38:34