View Javadoc

1   /**
2    * <copyright>
3    * </copyright>
4    *
5    * $Id$
6    */
7   package org.mod4j.dsl.datacontract.mm.DataContractDsl.impl;
8   
9   import java.util.Collection;
10  
11  import org.eclipse.emf.common.notify.Notification;
12  import org.eclipse.emf.common.notify.NotificationChain;
13  
14  import org.eclipse.emf.common.util.EList;
15  
16  import org.eclipse.emf.ecore.EClass;
17  import org.eclipse.emf.ecore.InternalEObject;
18  
19  import org.eclipse.emf.ecore.impl.ENotificationImpl;
20  
21  import org.eclipse.emf.ecore.util.EObjectContainmentEList;
22  import org.eclipse.emf.ecore.util.EcoreUtil;
23  import org.eclipse.emf.ecore.util.InternalEList;
24  
25  import org.mod4j.dsl.datacontract.mm.DataContractDsl.DataContractDslPackage;
26  import org.mod4j.dsl.datacontract.mm.DataContractDsl.DataContractModel;
27  import org.mod4j.dsl.datacontract.mm.DataContractDsl.EnumerationDto;
28  import org.mod4j.dsl.datacontract.mm.DataContractDsl.EnumerationDtoLiteral;
29  import org.mod4j.dsl.datacontract.mm.DataContractDsl.ExternalReference;
30  
31  /**
32   * <!-- begin-user-doc -->
33   * An implementation of the model object '<em><b>Enumeration Dto</b></em>'.
34   * <!-- end-user-doc -->
35   * <p>
36   * The following features are implemented:
37   * <ul>
38   *   <li>{@link org.mod4j.dsl.datacontract.mm.DataContractDsl.impl.EnumerationDtoImpl#getLiterals <em>Literals</em>}</li>
39   *   <li>{@link org.mod4j.dsl.datacontract.mm.DataContractDsl.impl.EnumerationDtoImpl#getBase <em>Base</em>}</li>
40   *   <li>{@link org.mod4j.dsl.datacontract.mm.DataContractDsl.impl.EnumerationDtoImpl#getDatacontractModel <em>Datacontract Model</em>}</li>
41   * </ul>
42   * </p>
43   *
44   * @generated
45   */
46  public class EnumerationDtoImpl extends ModelElementImpl implements EnumerationDto {
47  	/**
48       * The cached value of the '{@link #getLiterals() <em>Literals</em>}' containment reference list.
49       * <!-- begin-user-doc -->
50  	 * <!-- end-user-doc -->
51       * @see #getLiterals()
52       * @generated
53       * @ordered
54       */
55  	protected EList<EnumerationDtoLiteral> literals;
56  
57  	/**
58       * The cached value of the '{@link #getBase() <em>Base</em>}' reference.
59       * <!-- begin-user-doc -->
60  	 * <!-- end-user-doc -->
61       * @see #getBase()
62       * @generated
63       * @ordered
64       */
65  	protected ExternalReference base;
66  
67  	/**
68       * <!-- begin-user-doc -->
69  	 * <!-- end-user-doc -->
70       * @generated
71       */
72  	protected EnumerationDtoImpl() {
73          super();
74      }
75  
76  	/**
77       * <!-- begin-user-doc -->
78  	 * <!-- end-user-doc -->
79       * @generated
80       */
81  	@Override
82  	protected EClass eStaticClass() {
83          return DataContractDslPackage.Literals.ENUMERATION_DTO;
84      }
85  
86  	/**
87       * <!-- begin-user-doc -->
88  	 * <!-- end-user-doc -->
89       * @generated
90       */
91  	public EList<EnumerationDtoLiteral> getLiterals() {
92          if (literals == null) {
93              literals = new EObjectContainmentEList<EnumerationDtoLiteral>(EnumerationDtoLiteral.class, this, DataContractDslPackage.ENUMERATION_DTO__LITERALS);
94          }
95          return literals;
96      }
97  
98  	/**
99       * <!-- begin-user-doc -->
100 	 * <!-- end-user-doc -->
101      * @generated
102      */
103 	public ExternalReference getBase() {
104         if (base != null && base.eIsProxy()) {
105             InternalEObject oldBase = (InternalEObject)base;
106             base = (ExternalReference)eResolveProxy(oldBase);
107             if (base != oldBase) {
108                 if (eNotificationRequired())
109                     eNotify(new ENotificationImpl(this, Notification.RESOLVE, DataContractDslPackage.ENUMERATION_DTO__BASE, oldBase, base));
110             }
111         }
112         return base;
113     }
114 
115 	/**
116      * <!-- begin-user-doc -->
117 	 * <!-- end-user-doc -->
118      * @generated
119      */
120 	public ExternalReference basicGetBase() {
121         return base;
122     }
123 
124 	/**
125      * <!-- begin-user-doc -->
126 	 * <!-- end-user-doc -->
127      * @generated
128      */
129 	public void setBase(ExternalReference newBase) {
130         ExternalReference oldBase = base;
131         base = newBase;
132         if (eNotificationRequired())
133             eNotify(new ENotificationImpl(this, Notification.SET, DataContractDslPackage.ENUMERATION_DTO__BASE, oldBase, base));
134     }
135 
136 	/**
137      * <!-- begin-user-doc -->
138 	 * <!-- end-user-doc -->
139      * @generated
140      */
141 	public DataContractModel getDatacontractModel() {
142         if (eContainerFeatureID() != DataContractDslPackage.ENUMERATION_DTO__DATACONTRACT_MODEL) return null;
143         return (DataContractModel)eContainer();
144     }
145 
146 	/**
147      * <!-- begin-user-doc -->
148 	 * <!-- end-user-doc -->
149      * @generated
150      */
151 	public NotificationChain basicSetDatacontractModel(DataContractModel newDatacontractModel, NotificationChain msgs) {
152         msgs = eBasicSetContainer((InternalEObject)newDatacontractModel, DataContractDslPackage.ENUMERATION_DTO__DATACONTRACT_MODEL, msgs);
153         return msgs;
154     }
155 
156 	/**
157      * <!-- begin-user-doc -->
158 	 * <!-- end-user-doc -->
159      * @generated
160      */
161 	public void setDatacontractModel(DataContractModel newDatacontractModel) {
162         if (newDatacontractModel != eInternalContainer() || (eContainerFeatureID() != DataContractDslPackage.ENUMERATION_DTO__DATACONTRACT_MODEL && newDatacontractModel != null)) {
163             if (EcoreUtil.isAncestor(this, newDatacontractModel))
164                 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
165             NotificationChain msgs = null;
166             if (eInternalContainer() != null)
167                 msgs = eBasicRemoveFromContainer(msgs);
168             if (newDatacontractModel != null)
169                 msgs = ((InternalEObject)newDatacontractModel).eInverseAdd(this, DataContractDslPackage.DATA_CONTRACT_MODEL__ENUMERATIONS, DataContractModel.class, msgs);
170             msgs = basicSetDatacontractModel(newDatacontractModel, msgs);
171             if (msgs != null) msgs.dispatch();
172         }
173         else if (eNotificationRequired())
174             eNotify(new ENotificationImpl(this, Notification.SET, DataContractDslPackage.ENUMERATION_DTO__DATACONTRACT_MODEL, newDatacontractModel, newDatacontractModel));
175     }
176 
177 	/**
178      * <!-- begin-user-doc -->
179 	 * <!-- end-user-doc -->
180      * @generated
181      */
182 	@Override
183 	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
184         switch (featureID) {
185             case DataContractDslPackage.ENUMERATION_DTO__DATACONTRACT_MODEL:
186                 if (eInternalContainer() != null)
187                     msgs = eBasicRemoveFromContainer(msgs);
188                 return basicSetDatacontractModel((DataContractModel)otherEnd, msgs);
189         }
190         return super.eInverseAdd(otherEnd, featureID, msgs);
191     }
192 
193 	/**
194      * <!-- begin-user-doc -->
195 	 * <!-- end-user-doc -->
196      * @generated
197      */
198 	@Override
199 	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
200         switch (featureID) {
201             case DataContractDslPackage.ENUMERATION_DTO__LITERALS:
202                 return ((InternalEList<?>)getLiterals()).basicRemove(otherEnd, msgs);
203             case DataContractDslPackage.ENUMERATION_DTO__DATACONTRACT_MODEL:
204                 return basicSetDatacontractModel(null, msgs);
205         }
206         return super.eInverseRemove(otherEnd, featureID, msgs);
207     }
208 
209 	/**
210      * <!-- begin-user-doc -->
211 	 * <!-- end-user-doc -->
212      * @generated
213      */
214 	@Override
215 	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
216         switch (eContainerFeatureID()) {
217             case DataContractDslPackage.ENUMERATION_DTO__DATACONTRACT_MODEL:
218                 return eInternalContainer().eInverseRemove(this, DataContractDslPackage.DATA_CONTRACT_MODEL__ENUMERATIONS, DataContractModel.class, msgs);
219         }
220         return super.eBasicRemoveFromContainerFeature(msgs);
221     }
222 
223 	/**
224      * <!-- begin-user-doc -->
225 	 * <!-- end-user-doc -->
226      * @generated
227      */
228 	@Override
229 	public Object eGet(int featureID, boolean resolve, boolean coreType) {
230         switch (featureID) {
231             case DataContractDslPackage.ENUMERATION_DTO__LITERALS:
232                 return getLiterals();
233             case DataContractDslPackage.ENUMERATION_DTO__BASE:
234                 if (resolve) return getBase();
235                 return basicGetBase();
236             case DataContractDslPackage.ENUMERATION_DTO__DATACONTRACT_MODEL:
237                 return getDatacontractModel();
238         }
239         return super.eGet(featureID, resolve, coreType);
240     }
241 
242 	/**
243      * <!-- begin-user-doc -->
244 	 * <!-- end-user-doc -->
245      * @generated
246      */
247 	@SuppressWarnings("unchecked")
248 	@Override
249 	public void eSet(int featureID, Object newValue) {
250         switch (featureID) {
251             case DataContractDslPackage.ENUMERATION_DTO__LITERALS:
252                 getLiterals().clear();
253                 getLiterals().addAll((Collection<? extends EnumerationDtoLiteral>)newValue);
254                 return;
255             case DataContractDslPackage.ENUMERATION_DTO__BASE:
256                 setBase((ExternalReference)newValue);
257                 return;
258             case DataContractDslPackage.ENUMERATION_DTO__DATACONTRACT_MODEL:
259                 setDatacontractModel((DataContractModel)newValue);
260                 return;
261         }
262         super.eSet(featureID, newValue);
263     }
264 
265 	/**
266      * <!-- begin-user-doc -->
267 	 * <!-- end-user-doc -->
268      * @generated
269      */
270 	@Override
271 	public void eUnset(int featureID) {
272         switch (featureID) {
273             case DataContractDslPackage.ENUMERATION_DTO__LITERALS:
274                 getLiterals().clear();
275                 return;
276             case DataContractDslPackage.ENUMERATION_DTO__BASE:
277                 setBase((ExternalReference)null);
278                 return;
279             case DataContractDslPackage.ENUMERATION_DTO__DATACONTRACT_MODEL:
280                 setDatacontractModel((DataContractModel)null);
281                 return;
282         }
283         super.eUnset(featureID);
284     }
285 
286 	/**
287      * <!-- begin-user-doc -->
288 	 * <!-- end-user-doc -->
289      * @generated
290      */
291 	@Override
292 	public boolean eIsSet(int featureID) {
293         switch (featureID) {
294             case DataContractDslPackage.ENUMERATION_DTO__LITERALS:
295                 return literals != null && !literals.isEmpty();
296             case DataContractDslPackage.ENUMERATION_DTO__BASE:
297                 return base != null;
298             case DataContractDslPackage.ENUMERATION_DTO__DATACONTRACT_MODEL:
299                 return getDatacontractModel() != null;
300         }
301         return super.eIsSet(featureID);
302     }
303 
304 } //EnumerationDtoImpl