1
2
3
4
5
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46 public class EnumerationDtoImpl extends ModelElementImpl implements EnumerationDto {
47
48
49
50
51
52
53
54
55 protected EList<EnumerationDtoLiteral> literals;
56
57
58
59
60
61
62
63
64
65 protected ExternalReference base;
66
67
68
69
70
71
72 protected EnumerationDtoImpl() {
73 super();
74 }
75
76
77
78
79
80
81 @Override
82 protected EClass eStaticClass() {
83 return DataContractDslPackage.Literals.ENUMERATION_DTO;
84 }
85
86
87
88
89
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
100
101
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
117
118
119
120 public ExternalReference basicGetBase() {
121 return base;
122 }
123
124
125
126
127
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
138
139
140
141 public DataContractModel getDatacontractModel() {
142 if (eContainerFeatureID() != DataContractDslPackage.ENUMERATION_DTO__DATACONTRACT_MODEL) return null;
143 return (DataContractModel)eContainer();
144 }
145
146
147
148
149
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
158
159
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
179
180
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
195
196
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
211
212
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
225
226
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
244
245
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
267
268
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
288
289
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 }