1
2
3
4
5
6
7 package org.mod4j.dsl.service.mm.ServiceDsl.impl;
8
9 import org.eclipse.emf.common.notify.Notification;
10 import org.eclipse.emf.common.notify.NotificationChain;
11
12 import org.eclipse.emf.ecore.EClass;
13 import org.eclipse.emf.ecore.InternalEObject;
14
15 import org.eclipse.emf.ecore.impl.ENotificationImpl;
16
17 import org.eclipse.emf.ecore.util.EcoreUtil;
18
19 import org.mod4j.dsl.service.mm.ServiceDsl.CollectionType;
20 import org.mod4j.dsl.service.mm.ServiceDsl.CustomMethod;
21 import org.mod4j.dsl.service.mm.ServiceDsl.DtoReference;
22 import org.mod4j.dsl.service.mm.ServiceDsl.Parameter;
23 import org.mod4j.dsl.service.mm.ServiceDsl.ServiceDslPackage;
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 public class ParameterImpl extends ModelElementImpl implements Parameter {
41
42
43
44
45
46
47
48
49 protected DtoReference type;
50
51
52
53
54
55
56
57
58
59 protected static final CollectionType COLLECTION_EDEFAULT = CollectionType.SINGLE;
60
61
62
63
64
65
66
67
68 protected CollectionType collection = COLLECTION_EDEFAULT;
69
70
71
72
73
74
75 protected ParameterImpl() {
76 super();
77 }
78
79
80
81
82
83
84 @Override
85 protected EClass eStaticClass() {
86 return ServiceDslPackage.Literals.PARAMETER;
87 }
88
89
90
91
92
93
94 public DtoReference getType() {
95 if (type != null && type.eIsProxy()) {
96 InternalEObject oldType = (InternalEObject)type;
97 type = (DtoReference)eResolveProxy(oldType);
98 if (type != oldType) {
99 if (eNotificationRequired())
100 eNotify(new ENotificationImpl(this, Notification.RESOLVE, ServiceDslPackage.PARAMETER__TYPE, oldType, type));
101 }
102 }
103 return type;
104 }
105
106
107
108
109
110
111 public DtoReference basicGetType() {
112 return type;
113 }
114
115
116
117
118
119
120 public void setType(DtoReference newType) {
121 DtoReference oldType = type;
122 type = newType;
123 if (eNotificationRequired())
124 eNotify(new ENotificationImpl(this, Notification.SET, ServiceDslPackage.PARAMETER__TYPE, oldType, type));
125 }
126
127
128
129
130
131
132 public CustomMethod getMethod() {
133 if (eContainerFeatureID() != ServiceDslPackage.PARAMETER__METHOD) return null;
134 return (CustomMethod)eContainer();
135 }
136
137
138
139
140
141
142 public NotificationChain basicSetMethod(CustomMethod newMethod, NotificationChain msgs) {
143 msgs = eBasicSetContainer((InternalEObject)newMethod, ServiceDslPackage.PARAMETER__METHOD, msgs);
144 return msgs;
145 }
146
147
148
149
150
151
152 public void setMethod(CustomMethod newMethod) {
153 if (newMethod != eInternalContainer() || (eContainerFeatureID() != ServiceDslPackage.PARAMETER__METHOD && newMethod != null)) {
154 if (EcoreUtil.isAncestor(this, newMethod))
155 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
156 NotificationChain msgs = null;
157 if (eInternalContainer() != null)
158 msgs = eBasicRemoveFromContainer(msgs);
159 if (newMethod != null)
160 msgs = ((InternalEObject)newMethod).eInverseAdd(this, ServiceDslPackage.CUSTOM_METHOD__IN_PARAMETERS, CustomMethod.class, msgs);
161 msgs = basicSetMethod(newMethod, msgs);
162 if (msgs != null) msgs.dispatch();
163 }
164 else if (eNotificationRequired())
165 eNotify(new ENotificationImpl(this, Notification.SET, ServiceDslPackage.PARAMETER__METHOD, newMethod, newMethod));
166 }
167
168
169
170
171
172
173 public CollectionType getCollection() {
174 return collection;
175 }
176
177
178
179
180
181
182 public void setCollection(CollectionType newCollection) {
183 CollectionType oldCollection = collection;
184 collection = newCollection == null ? COLLECTION_EDEFAULT : newCollection;
185 if (eNotificationRequired())
186 eNotify(new ENotificationImpl(this, Notification.SET, ServiceDslPackage.PARAMETER__COLLECTION, oldCollection, collection));
187 }
188
189
190
191
192
193
194 @Override
195 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
196 switch (featureID) {
197 case ServiceDslPackage.PARAMETER__METHOD:
198 if (eInternalContainer() != null)
199 msgs = eBasicRemoveFromContainer(msgs);
200 return basicSetMethod((CustomMethod)otherEnd, msgs);
201 }
202 return super.eInverseAdd(otherEnd, featureID, msgs);
203 }
204
205
206
207
208
209
210 @Override
211 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
212 switch (featureID) {
213 case ServiceDslPackage.PARAMETER__METHOD:
214 return basicSetMethod(null, msgs);
215 }
216 return super.eInverseRemove(otherEnd, featureID, msgs);
217 }
218
219
220
221
222
223
224 @Override
225 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
226 switch (eContainerFeatureID()) {
227 case ServiceDslPackage.PARAMETER__METHOD:
228 return eInternalContainer().eInverseRemove(this, ServiceDslPackage.CUSTOM_METHOD__IN_PARAMETERS, CustomMethod.class, msgs);
229 }
230 return super.eBasicRemoveFromContainerFeature(msgs);
231 }
232
233
234
235
236
237
238 @Override
239 public Object eGet(int featureID, boolean resolve, boolean coreType) {
240 switch (featureID) {
241 case ServiceDslPackage.PARAMETER__TYPE:
242 if (resolve) return getType();
243 return basicGetType();
244 case ServiceDslPackage.PARAMETER__METHOD:
245 return getMethod();
246 case ServiceDslPackage.PARAMETER__COLLECTION:
247 return getCollection();
248 }
249 return super.eGet(featureID, resolve, coreType);
250 }
251
252
253
254
255
256
257 @Override
258 public void eSet(int featureID, Object newValue) {
259 switch (featureID) {
260 case ServiceDslPackage.PARAMETER__TYPE:
261 setType((DtoReference)newValue);
262 return;
263 case ServiceDslPackage.PARAMETER__METHOD:
264 setMethod((CustomMethod)newValue);
265 return;
266 case ServiceDslPackage.PARAMETER__COLLECTION:
267 setCollection((CollectionType)newValue);
268 return;
269 }
270 super.eSet(featureID, newValue);
271 }
272
273
274
275
276
277
278 @Override
279 public void eUnset(int featureID) {
280 switch (featureID) {
281 case ServiceDslPackage.PARAMETER__TYPE:
282 setType((DtoReference)null);
283 return;
284 case ServiceDslPackage.PARAMETER__METHOD:
285 setMethod((CustomMethod)null);
286 return;
287 case ServiceDslPackage.PARAMETER__COLLECTION:
288 setCollection(COLLECTION_EDEFAULT);
289 return;
290 }
291 super.eUnset(featureID);
292 }
293
294
295
296
297
298
299 @Override
300 public boolean eIsSet(int featureID) {
301 switch (featureID) {
302 case ServiceDslPackage.PARAMETER__TYPE:
303 return type != null;
304 case ServiceDslPackage.PARAMETER__METHOD:
305 return getMethod() != null;
306 case ServiceDslPackage.PARAMETER__COLLECTION:
307 return collection != COLLECTION_EDEFAULT;
308 }
309 return super.eIsSet(featureID);
310 }
311
312
313
314
315
316
317 @Override
318 public String toString() {
319 if (eIsProxy()) return super.toString();
320
321 StringBuffer result = new StringBuffer(super.toString());
322 result.append(" (collection: ");
323 result.append(collection);
324 result.append(')');
325 return result.toString();
326 }
327
328 }