View Javadoc

1   /**
2    * <copyright>
3    * </copyright>
4    *
5    * $Id$
6    */
7   package BusinessDomainDsl.impl;
8   
9   import BusinessDomainDsl.AbstractType;
10  import BusinessDomainDsl.BusinessDomainDslPackage;
11  import BusinessDomainDsl.BusinessDomainModel;
12  import BusinessDomainDsl.Property;
13  
14  import java.util.Collection;
15  
16  import org.eclipse.emf.common.notify.Notification;
17  import org.eclipse.emf.common.notify.NotificationChain;
18  
19  import org.eclipse.emf.common.util.EList;
20  
21  import org.eclipse.emf.ecore.EClass;
22  import org.eclipse.emf.ecore.InternalEObject;
23  
24  import org.eclipse.emf.ecore.impl.ENotificationImpl;
25  
26  import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
27  import org.eclipse.emf.ecore.util.EcoreUtil;
28  import org.eclipse.emf.ecore.util.InternalEList;
29  
30  /**
31   * <!-- begin-user-doc -->
32   * An implementation of the model object '<em><b>Abstract Type</b></em>'.
33   * <!-- end-user-doc -->
34   * <p>
35   * The following features are implemented:
36   * <ul>
37   *   <li>{@link BusinessDomainDsl.impl.AbstractTypeImpl#getProperties <em>Properties</em>}</li>
38   *   <li>{@link BusinessDomainDsl.impl.AbstractTypeImpl#getModel <em>Model</em>}</li>
39   * </ul>
40   * </p>
41   *
42   * @generated
43   */
44  public abstract class AbstractTypeImpl extends ModelElementImpl implements AbstractType {
45  	/**
46       * The cached value of the '{@link #getProperties() <em>Properties</em>}' containment reference list.
47       * <!-- begin-user-doc -->
48  	 * <!-- end-user-doc -->
49       * @see #getProperties()
50       * @generated
51       * @ordered
52       */
53  	protected EList<Property> properties;
54  
55  	/**
56       * <!-- begin-user-doc -->
57  	 * <!-- end-user-doc -->
58       * @generated
59       */
60  	protected AbstractTypeImpl() {
61          super();
62      }
63  
64  	/**
65       * <!-- begin-user-doc -->
66  	 * <!-- end-user-doc -->
67       * @generated
68       */
69  	@Override
70  	protected EClass eStaticClass() {
71          return BusinessDomainDslPackage.Literals.ABSTRACT_TYPE;
72      }
73  
74  	/**
75       * <!-- begin-user-doc -->
76  	 * <!-- end-user-doc -->
77       * @generated
78       */
79  	public EList<Property> getProperties() {
80          if (properties == null) {
81              properties = new EObjectContainmentWithInverseEList<Property>(Property.class, this, BusinessDomainDslPackage.ABSTRACT_TYPE__PROPERTIES, BusinessDomainDslPackage.PROPERTY__OWNING_TYPE);
82          }
83          return properties;
84      }
85  
86  	/**
87       * <!-- begin-user-doc -->
88  	 * <!-- end-user-doc -->
89       * @generated
90       */
91  	public BusinessDomainModel getModel() {
92          if (eContainerFeatureID() != BusinessDomainDslPackage.ABSTRACT_TYPE__MODEL) return null;
93          return (BusinessDomainModel)eContainer();
94      }
95  
96  	/**
97       * <!-- begin-user-doc -->
98  	 * <!-- end-user-doc -->
99       * @generated
100      */
101 	public NotificationChain basicSetModel(BusinessDomainModel newModel, NotificationChain msgs) {
102         msgs = eBasicSetContainer((InternalEObject)newModel, BusinessDomainDslPackage.ABSTRACT_TYPE__MODEL, msgs);
103         return msgs;
104     }
105 
106 	/**
107      * <!-- begin-user-doc -->
108 	 * <!-- end-user-doc -->
109      * @generated
110      */
111 	public void setModel(BusinessDomainModel newModel) {
112         if (newModel != eInternalContainer() || (eContainerFeatureID() != BusinessDomainDslPackage.ABSTRACT_TYPE__MODEL && newModel != null)) {
113             if (EcoreUtil.isAncestor(this, newModel))
114                 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
115             NotificationChain msgs = null;
116             if (eInternalContainer() != null)
117                 msgs = eBasicRemoveFromContainer(msgs);
118             if (newModel != null)
119                 msgs = ((InternalEObject)newModel).eInverseAdd(this, BusinessDomainDslPackage.BUSINESS_DOMAIN_MODEL__TYPES, BusinessDomainModel.class, msgs);
120             msgs = basicSetModel(newModel, msgs);
121             if (msgs != null) msgs.dispatch();
122         }
123         else if (eNotificationRequired())
124             eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.ABSTRACT_TYPE__MODEL, newModel, newModel));
125     }
126 
127 	/**
128      * <!-- begin-user-doc -->
129 	 * <!-- end-user-doc -->
130      * @generated
131      */
132 	@SuppressWarnings("unchecked")
133 	@Override
134 	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
135         switch (featureID) {
136             case BusinessDomainDslPackage.ABSTRACT_TYPE__PROPERTIES:
137                 return ((InternalEList<InternalEObject>)(InternalEList<?>)getProperties()).basicAdd(otherEnd, msgs);
138             case BusinessDomainDslPackage.ABSTRACT_TYPE__MODEL:
139                 if (eInternalContainer() != null)
140                     msgs = eBasicRemoveFromContainer(msgs);
141                 return basicSetModel((BusinessDomainModel)otherEnd, msgs);
142         }
143         return super.eInverseAdd(otherEnd, featureID, msgs);
144     }
145 
146 	/**
147      * <!-- begin-user-doc -->
148 	 * <!-- end-user-doc -->
149      * @generated
150      */
151 	@Override
152 	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
153         switch (featureID) {
154             case BusinessDomainDslPackage.ABSTRACT_TYPE__PROPERTIES:
155                 return ((InternalEList<?>)getProperties()).basicRemove(otherEnd, msgs);
156             case BusinessDomainDslPackage.ABSTRACT_TYPE__MODEL:
157                 return basicSetModel(null, msgs);
158         }
159         return super.eInverseRemove(otherEnd, featureID, msgs);
160     }
161 
162 	/**
163      * <!-- begin-user-doc -->
164 	 * <!-- end-user-doc -->
165      * @generated
166      */
167 	@Override
168 	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
169         switch (eContainerFeatureID()) {
170             case BusinessDomainDslPackage.ABSTRACT_TYPE__MODEL:
171                 return eInternalContainer().eInverseRemove(this, BusinessDomainDslPackage.BUSINESS_DOMAIN_MODEL__TYPES, BusinessDomainModel.class, msgs);
172         }
173         return super.eBasicRemoveFromContainerFeature(msgs);
174     }
175 
176 	/**
177      * <!-- begin-user-doc -->
178 	 * <!-- end-user-doc -->
179      * @generated
180      */
181 	@Override
182 	public Object eGet(int featureID, boolean resolve, boolean coreType) {
183         switch (featureID) {
184             case BusinessDomainDslPackage.ABSTRACT_TYPE__PROPERTIES:
185                 return getProperties();
186             case BusinessDomainDslPackage.ABSTRACT_TYPE__MODEL:
187                 return getModel();
188         }
189         return super.eGet(featureID, resolve, coreType);
190     }
191 
192 	/**
193      * <!-- begin-user-doc -->
194 	 * <!-- end-user-doc -->
195      * @generated
196      */
197 	@SuppressWarnings("unchecked")
198 	@Override
199 	public void eSet(int featureID, Object newValue) {
200         switch (featureID) {
201             case BusinessDomainDslPackage.ABSTRACT_TYPE__PROPERTIES:
202                 getProperties().clear();
203                 getProperties().addAll((Collection<? extends Property>)newValue);
204                 return;
205             case BusinessDomainDslPackage.ABSTRACT_TYPE__MODEL:
206                 setModel((BusinessDomainModel)newValue);
207                 return;
208         }
209         super.eSet(featureID, newValue);
210     }
211 
212 	/**
213      * <!-- begin-user-doc -->
214 	 * <!-- end-user-doc -->
215      * @generated
216      */
217 	@Override
218 	public void eUnset(int featureID) {
219         switch (featureID) {
220             case BusinessDomainDslPackage.ABSTRACT_TYPE__PROPERTIES:
221                 getProperties().clear();
222                 return;
223             case BusinessDomainDslPackage.ABSTRACT_TYPE__MODEL:
224                 setModel((BusinessDomainModel)null);
225                 return;
226         }
227         super.eUnset(featureID);
228     }
229 
230 	/**
231      * <!-- begin-user-doc -->
232 	 * <!-- end-user-doc -->
233      * @generated
234      */
235 	@Override
236 	public boolean eIsSet(int featureID) {
237         switch (featureID) {
238             case BusinessDomainDslPackage.ABSTRACT_TYPE__PROPERTIES:
239                 return properties != null && !properties.isEmpty();
240             case BusinessDomainDslPackage.ABSTRACT_TYPE__MODEL:
241                 return getModel() != null;
242         }
243         return super.eIsSet(featureID);
244     }
245 
246 } //AbstractTypeImpl