1
2
3
4
5
6
7 package org.mod4j.dsl.datacontract.mm.DataContractDsl.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.datacontract.mm.DataContractDsl.BusinessClassDto;
20 import org.mod4j.dsl.datacontract.mm.DataContractDsl.CustomDto;
21 import org.mod4j.dsl.datacontract.mm.DataContractDsl.DataContractDslPackage;
22 import org.mod4j.dsl.datacontract.mm.DataContractDsl.DtoProperty;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 public class DtoPropertyImpl extends ModelElementImpl implements DtoProperty {
43
44
45
46
47
48
49
50
51 protected static final String DATA_TYPE_EDEFAULT = null;
52
53
54
55
56
57
58
59
60
61 protected String dataType = DATA_TYPE_EDEFAULT;
62
63
64
65
66
67
68
69
70
71 protected static final boolean MANDATORY_FOR_CREATION_EDEFAULT = false;
72
73
74
75
76
77
78
79
80
81 protected boolean mandatoryForCreation = MANDATORY_FOR_CREATION_EDEFAULT;
82
83
84
85
86
87
88
89
90
91 protected static final boolean NULLABLE_EDEFAULT = true;
92
93
94
95
96
97
98
99
100
101 protected boolean nullable = NULLABLE_EDEFAULT;
102
103
104
105
106
107
108
109
110
111 protected static final boolean WRITABLE_EDEFAULT = true;
112
113
114
115
116
117
118
119
120
121 protected boolean writable = WRITABLE_EDEFAULT;
122
123
124
125
126
127
128 protected DtoPropertyImpl() {
129 super();
130 }
131
132
133
134
135
136
137 @Override
138 protected EClass eStaticClass() {
139 return DataContractDslPackage.Literals.DTO_PROPERTY;
140 }
141
142
143
144
145
146
147 public String getDataType() {
148 return dataType;
149 }
150
151
152
153
154
155
156 public void setDataType(String newDataType) {
157 String oldDataType = dataType;
158 dataType = newDataType;
159 if (eNotificationRequired())
160 eNotify(new ENotificationImpl(this, Notification.SET, DataContractDslPackage.DTO_PROPERTY__DATA_TYPE, oldDataType, dataType));
161 }
162
163
164
165
166
167
168 public BusinessClassDto getBusinessClassDto() {
169 if (eContainerFeatureID() != DataContractDslPackage.DTO_PROPERTY__BUSINESS_CLASS_DTO) return null;
170 return (BusinessClassDto)eContainer();
171 }
172
173
174
175
176
177
178 public NotificationChain basicSetBusinessClassDto(BusinessClassDto newBusinessClassDto, NotificationChain msgs) {
179 msgs = eBasicSetContainer((InternalEObject)newBusinessClassDto, DataContractDslPackage.DTO_PROPERTY__BUSINESS_CLASS_DTO, msgs);
180 return msgs;
181 }
182
183
184
185
186
187
188 public void setBusinessClassDto(BusinessClassDto newBusinessClassDto) {
189 if (newBusinessClassDto != eInternalContainer() || (eContainerFeatureID() != DataContractDslPackage.DTO_PROPERTY__BUSINESS_CLASS_DTO && newBusinessClassDto != null)) {
190 if (EcoreUtil.isAncestor(this, newBusinessClassDto))
191 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
192 NotificationChain msgs = null;
193 if (eInternalContainer() != null)
194 msgs = eBasicRemoveFromContainer(msgs);
195 if (newBusinessClassDto != null)
196 msgs = ((InternalEObject)newBusinessClassDto).eInverseAdd(this, DataContractDslPackage.BUSINESS_CLASS_DTO__PROPERTIES, BusinessClassDto.class, msgs);
197 msgs = basicSetBusinessClassDto(newBusinessClassDto, msgs);
198 if (msgs != null) msgs.dispatch();
199 }
200 else if (eNotificationRequired())
201 eNotify(new ENotificationImpl(this, Notification.SET, DataContractDslPackage.DTO_PROPERTY__BUSINESS_CLASS_DTO, newBusinessClassDto, newBusinessClassDto));
202 }
203
204
205
206
207
208
209 public CustomDto getCustomDto() {
210 if (eContainerFeatureID() != DataContractDslPackage.DTO_PROPERTY__CUSTOM_DTO) return null;
211 return (CustomDto)eContainer();
212 }
213
214
215
216
217
218
219 public NotificationChain basicSetCustomDto(CustomDto newCustomDto, NotificationChain msgs) {
220 msgs = eBasicSetContainer((InternalEObject)newCustomDto, DataContractDslPackage.DTO_PROPERTY__CUSTOM_DTO, msgs);
221 return msgs;
222 }
223
224
225
226
227
228
229 public void setCustomDto(CustomDto newCustomDto) {
230 if (newCustomDto != eInternalContainer() || (eContainerFeatureID() != DataContractDslPackage.DTO_PROPERTY__CUSTOM_DTO && newCustomDto != null)) {
231 if (EcoreUtil.isAncestor(this, newCustomDto))
232 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
233 NotificationChain msgs = null;
234 if (eInternalContainer() != null)
235 msgs = eBasicRemoveFromContainer(msgs);
236 if (newCustomDto != null)
237 msgs = ((InternalEObject)newCustomDto).eInverseAdd(this, DataContractDslPackage.CUSTOM_DTO__PROPERTIES, CustomDto.class, msgs);
238 msgs = basicSetCustomDto(newCustomDto, msgs);
239 if (msgs != null) msgs.dispatch();
240 }
241 else if (eNotificationRequired())
242 eNotify(new ENotificationImpl(this, Notification.SET, DataContractDslPackage.DTO_PROPERTY__CUSTOM_DTO, newCustomDto, newCustomDto));
243 }
244
245
246
247
248
249
250 public boolean isMandatoryForCreation() {
251 return mandatoryForCreation;
252 }
253
254
255
256
257
258
259 public void setMandatoryForCreation(boolean newMandatoryForCreation) {
260 boolean oldMandatoryForCreation = mandatoryForCreation;
261 mandatoryForCreation = newMandatoryForCreation;
262 if (eNotificationRequired())
263 eNotify(new ENotificationImpl(this, Notification.SET, DataContractDslPackage.DTO_PROPERTY__MANDATORY_FOR_CREATION, oldMandatoryForCreation, mandatoryForCreation));
264 }
265
266
267
268
269
270
271 public boolean isNullable() {
272 return nullable;
273 }
274
275
276
277
278
279
280 public void setNullable(boolean newNullable) {
281 boolean oldNullable = nullable;
282 nullable = newNullable;
283 if (eNotificationRequired())
284 eNotify(new ENotificationImpl(this, Notification.SET, DataContractDslPackage.DTO_PROPERTY__NULLABLE, oldNullable, nullable));
285 }
286
287
288
289
290
291
292 public boolean isWritable() {
293 return writable;
294 }
295
296
297
298
299
300
301 public void setWritable(boolean newWritable) {
302 boolean oldWritable = writable;
303 writable = newWritable;
304 if (eNotificationRequired())
305 eNotify(new ENotificationImpl(this, Notification.SET, DataContractDslPackage.DTO_PROPERTY__WRITABLE, oldWritable, writable));
306 }
307
308
309
310
311
312
313 @Override
314 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
315 switch (featureID) {
316 case DataContractDslPackage.DTO_PROPERTY__BUSINESS_CLASS_DTO:
317 if (eInternalContainer() != null)
318 msgs = eBasicRemoveFromContainer(msgs);
319 return basicSetBusinessClassDto((BusinessClassDto)otherEnd, msgs);
320 case DataContractDslPackage.DTO_PROPERTY__CUSTOM_DTO:
321 if (eInternalContainer() != null)
322 msgs = eBasicRemoveFromContainer(msgs);
323 return basicSetCustomDto((CustomDto)otherEnd, msgs);
324 }
325 return super.eInverseAdd(otherEnd, featureID, msgs);
326 }
327
328
329
330
331
332
333 @Override
334 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
335 switch (featureID) {
336 case DataContractDslPackage.DTO_PROPERTY__BUSINESS_CLASS_DTO:
337 return basicSetBusinessClassDto(null, msgs);
338 case DataContractDslPackage.DTO_PROPERTY__CUSTOM_DTO:
339 return basicSetCustomDto(null, msgs);
340 }
341 return super.eInverseRemove(otherEnd, featureID, msgs);
342 }
343
344
345
346
347
348
349 @Override
350 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
351 switch (eContainerFeatureID()) {
352 case DataContractDslPackage.DTO_PROPERTY__BUSINESS_CLASS_DTO:
353 return eInternalContainer().eInverseRemove(this, DataContractDslPackage.BUSINESS_CLASS_DTO__PROPERTIES, BusinessClassDto.class, msgs);
354 case DataContractDslPackage.DTO_PROPERTY__CUSTOM_DTO:
355 return eInternalContainer().eInverseRemove(this, DataContractDslPackage.CUSTOM_DTO__PROPERTIES, CustomDto.class, msgs);
356 }
357 return super.eBasicRemoveFromContainerFeature(msgs);
358 }
359
360
361
362
363
364
365 @Override
366 public Object eGet(int featureID, boolean resolve, boolean coreType) {
367 switch (featureID) {
368 case DataContractDslPackage.DTO_PROPERTY__DATA_TYPE:
369 return getDataType();
370 case DataContractDslPackage.DTO_PROPERTY__BUSINESS_CLASS_DTO:
371 return getBusinessClassDto();
372 case DataContractDslPackage.DTO_PROPERTY__CUSTOM_DTO:
373 return getCustomDto();
374 case DataContractDslPackage.DTO_PROPERTY__MANDATORY_FOR_CREATION:
375 return isMandatoryForCreation();
376 case DataContractDslPackage.DTO_PROPERTY__NULLABLE:
377 return isNullable();
378 case DataContractDslPackage.DTO_PROPERTY__WRITABLE:
379 return isWritable();
380 }
381 return super.eGet(featureID, resolve, coreType);
382 }
383
384
385
386
387
388
389 @Override
390 public void eSet(int featureID, Object newValue) {
391 switch (featureID) {
392 case DataContractDslPackage.DTO_PROPERTY__DATA_TYPE:
393 setDataType((String)newValue);
394 return;
395 case DataContractDslPackage.DTO_PROPERTY__BUSINESS_CLASS_DTO:
396 setBusinessClassDto((BusinessClassDto)newValue);
397 return;
398 case DataContractDslPackage.DTO_PROPERTY__CUSTOM_DTO:
399 setCustomDto((CustomDto)newValue);
400 return;
401 case DataContractDslPackage.DTO_PROPERTY__MANDATORY_FOR_CREATION:
402 setMandatoryForCreation((Boolean)newValue);
403 return;
404 case DataContractDslPackage.DTO_PROPERTY__NULLABLE:
405 setNullable((Boolean)newValue);
406 return;
407 case DataContractDslPackage.DTO_PROPERTY__WRITABLE:
408 setWritable((Boolean)newValue);
409 return;
410 }
411 super.eSet(featureID, newValue);
412 }
413
414
415
416
417
418
419 @Override
420 public void eUnset(int featureID) {
421 switch (featureID) {
422 case DataContractDslPackage.DTO_PROPERTY__DATA_TYPE:
423 setDataType(DATA_TYPE_EDEFAULT);
424 return;
425 case DataContractDslPackage.DTO_PROPERTY__BUSINESS_CLASS_DTO:
426 setBusinessClassDto((BusinessClassDto)null);
427 return;
428 case DataContractDslPackage.DTO_PROPERTY__CUSTOM_DTO:
429 setCustomDto((CustomDto)null);
430 return;
431 case DataContractDslPackage.DTO_PROPERTY__MANDATORY_FOR_CREATION:
432 setMandatoryForCreation(MANDATORY_FOR_CREATION_EDEFAULT);
433 return;
434 case DataContractDslPackage.DTO_PROPERTY__NULLABLE:
435 setNullable(NULLABLE_EDEFAULT);
436 return;
437 case DataContractDslPackage.DTO_PROPERTY__WRITABLE:
438 setWritable(WRITABLE_EDEFAULT);
439 return;
440 }
441 super.eUnset(featureID);
442 }
443
444
445
446
447
448
449 @Override
450 public boolean eIsSet(int featureID) {
451 switch (featureID) {
452 case DataContractDslPackage.DTO_PROPERTY__DATA_TYPE:
453 return DATA_TYPE_EDEFAULT == null ? dataType != null : !DATA_TYPE_EDEFAULT.equals(dataType);
454 case DataContractDslPackage.DTO_PROPERTY__BUSINESS_CLASS_DTO:
455 return getBusinessClassDto() != null;
456 case DataContractDslPackage.DTO_PROPERTY__CUSTOM_DTO:
457 return getCustomDto() != null;
458 case DataContractDslPackage.DTO_PROPERTY__MANDATORY_FOR_CREATION:
459 return mandatoryForCreation != MANDATORY_FOR_CREATION_EDEFAULT;
460 case DataContractDslPackage.DTO_PROPERTY__NULLABLE:
461 return nullable != NULLABLE_EDEFAULT;
462 case DataContractDslPackage.DTO_PROPERTY__WRITABLE:
463 return writable != WRITABLE_EDEFAULT;
464 }
465 return super.eIsSet(featureID);
466 }
467
468
469
470
471
472
473 @Override
474 public String toString() {
475 if (eIsProxy()) return super.toString();
476
477 StringBuffer result = new StringBuffer(super.toString());
478 result.append(" (dataType: ");
479 result.append(dataType);
480 result.append(", mandatoryForCreation: ");
481 result.append(mandatoryForCreation);
482 result.append(", nullable: ");
483 result.append(nullable);
484 result.append(", writable: ");
485 result.append(writable);
486 result.append(')');
487 return result.toString();
488 }
489
490 }