View Javadoc

1   /**
2    * <copyright>
3    * </copyright>
4    *
5    * $Id$
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   * <!-- begin-user-doc -->
26   * An implementation of the model object '<em><b>Dto Property</b></em>'.
27   * <!-- end-user-doc -->
28   * <p>
29   * The following features are implemented:
30   * <ul>
31   *   <li>{@link org.mod4j.dsl.datacontract.mm.DataContractDsl.impl.DtoPropertyImpl#getDataType <em>Data Type</em>}</li>
32   *   <li>{@link org.mod4j.dsl.datacontract.mm.DataContractDsl.impl.DtoPropertyImpl#getBusinessClassDto <em>Business Class Dto</em>}</li>
33   *   <li>{@link org.mod4j.dsl.datacontract.mm.DataContractDsl.impl.DtoPropertyImpl#getCustomDto <em>Custom Dto</em>}</li>
34   *   <li>{@link org.mod4j.dsl.datacontract.mm.DataContractDsl.impl.DtoPropertyImpl#isMandatoryForCreation <em>Mandatory For Creation</em>}</li>
35   *   <li>{@link org.mod4j.dsl.datacontract.mm.DataContractDsl.impl.DtoPropertyImpl#isNullable <em>Nullable</em>}</li>
36   *   <li>{@link org.mod4j.dsl.datacontract.mm.DataContractDsl.impl.DtoPropertyImpl#isWritable <em>Writable</em>}</li>
37   * </ul>
38   * </p>
39   *
40   * @generated
41   */
42  public class DtoPropertyImpl extends ModelElementImpl implements DtoProperty {
43  	/**
44       * The default value of the '{@link #getDataType() <em>Data Type</em>}' attribute.
45       * <!-- begin-user-doc -->
46  	 * <!-- end-user-doc -->
47       * @see #getDataType()
48       * @generated
49       * @ordered
50       */
51  	protected static final String DATA_TYPE_EDEFAULT = null;
52  
53  	/**
54       * The cached value of the '{@link #getDataType() <em>Data Type</em>}' attribute.
55       * <!-- begin-user-doc -->
56  	 * <!-- end-user-doc -->
57       * @see #getDataType()
58       * @generated
59       * @ordered
60       */
61  	protected String dataType = DATA_TYPE_EDEFAULT;
62  
63  	/**
64       * The default value of the '{@link #isMandatoryForCreation() <em>Mandatory For Creation</em>}' attribute.
65       * <!-- begin-user-doc -->
66  	 * <!-- end-user-doc -->
67       * @see #isMandatoryForCreation()
68       * @generated
69       * @ordered
70       */
71  	protected static final boolean MANDATORY_FOR_CREATION_EDEFAULT = false;
72  
73  	/**
74       * The cached value of the '{@link #isMandatoryForCreation() <em>Mandatory For Creation</em>}' attribute.
75       * <!-- begin-user-doc -->
76  	 * <!-- end-user-doc -->
77       * @see #isMandatoryForCreation()
78       * @generated
79       * @ordered
80       */
81  	protected boolean mandatoryForCreation = MANDATORY_FOR_CREATION_EDEFAULT;
82  
83  	/**
84       * The default value of the '{@link #isNullable() <em>Nullable</em>}' attribute.
85       * <!-- begin-user-doc -->
86  	 * <!-- end-user-doc -->
87       * @see #isNullable()
88       * @generated
89       * @ordered
90       */
91  	protected static final boolean NULLABLE_EDEFAULT = true;
92  
93  	/**
94       * The cached value of the '{@link #isNullable() <em>Nullable</em>}' attribute.
95       * <!-- begin-user-doc -->
96  	 * <!-- end-user-doc -->
97       * @see #isNullable()
98       * @generated
99       * @ordered
100      */
101 	protected boolean nullable = NULLABLE_EDEFAULT;
102 
103 	/**
104      * The default value of the '{@link #isWritable() <em>Writable</em>}' attribute.
105      * <!-- begin-user-doc -->
106 	 * <!-- end-user-doc -->
107      * @see #isWritable()
108      * @generated
109      * @ordered
110      */
111 	protected static final boolean WRITABLE_EDEFAULT = true;
112 
113 	/**
114      * The cached value of the '{@link #isWritable() <em>Writable</em>}' attribute.
115      * <!-- begin-user-doc -->
116 	 * <!-- end-user-doc -->
117      * @see #isWritable()
118      * @generated
119      * @ordered
120      */
121 	protected boolean writable = WRITABLE_EDEFAULT;
122 
123 	/**
124      * <!-- begin-user-doc -->
125 	 * <!-- end-user-doc -->
126      * @generated
127      */
128 	protected DtoPropertyImpl() {
129         super();
130     }
131 
132 	/**
133      * <!-- begin-user-doc -->
134 	 * <!-- end-user-doc -->
135      * @generated
136      */
137 	@Override
138 	protected EClass eStaticClass() {
139         return DataContractDslPackage.Literals.DTO_PROPERTY;
140     }
141 
142 	/**
143      * <!-- begin-user-doc -->
144 	 * <!-- end-user-doc -->
145      * @generated
146      */
147 	public String getDataType() {
148         return dataType;
149     }
150 
151 	/**
152      * <!-- begin-user-doc -->
153 	 * <!-- end-user-doc -->
154      * @generated
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      * <!-- begin-user-doc -->
165 	 * <!-- end-user-doc -->
166      * @generated
167      */
168 	public BusinessClassDto getBusinessClassDto() {
169         if (eContainerFeatureID() != DataContractDslPackage.DTO_PROPERTY__BUSINESS_CLASS_DTO) return null;
170         return (BusinessClassDto)eContainer();
171     }
172 
173 	/**
174      * <!-- begin-user-doc -->
175 	 * <!-- end-user-doc -->
176      * @generated
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      * <!-- begin-user-doc -->
185 	 * <!-- end-user-doc -->
186      * @generated
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      * <!-- begin-user-doc -->
206 	 * <!-- end-user-doc -->
207      * @generated
208      */
209 	public CustomDto getCustomDto() {
210         if (eContainerFeatureID() != DataContractDslPackage.DTO_PROPERTY__CUSTOM_DTO) return null;
211         return (CustomDto)eContainer();
212     }
213 
214 	/**
215      * <!-- begin-user-doc -->
216 	 * <!-- end-user-doc -->
217      * @generated
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      * <!-- begin-user-doc -->
226 	 * <!-- end-user-doc -->
227      * @generated
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      * <!-- begin-user-doc -->
247 	 * <!-- end-user-doc -->
248      * @generated
249      */
250 	public boolean isMandatoryForCreation() {
251         return mandatoryForCreation;
252     }
253 
254 	/**
255      * <!-- begin-user-doc -->
256 	 * <!-- end-user-doc -->
257      * @generated
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      * <!-- begin-user-doc -->
268 	 * <!-- end-user-doc -->
269      * @generated
270      */
271 	public boolean isNullable() {
272         return nullable;
273     }
274 
275 	/**
276      * <!-- begin-user-doc -->
277 	 * <!-- end-user-doc -->
278      * @generated
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      * <!-- begin-user-doc -->
289 	 * <!-- end-user-doc -->
290      * @generated
291      */
292 	public boolean isWritable() {
293         return writable;
294     }
295 
296 	/**
297      * <!-- begin-user-doc -->
298 	 * <!-- end-user-doc -->
299      * @generated
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      * <!-- begin-user-doc -->
310 	 * <!-- end-user-doc -->
311      * @generated
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      * <!-- begin-user-doc -->
330 	 * <!-- end-user-doc -->
331      * @generated
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      * <!-- begin-user-doc -->
346 	 * <!-- end-user-doc -->
347      * @generated
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      * <!-- begin-user-doc -->
362 	 * <!-- end-user-doc -->
363      * @generated
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      * <!-- begin-user-doc -->
386 	 * <!-- end-user-doc -->
387      * @generated
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      * <!-- begin-user-doc -->
416 	 * <!-- end-user-doc -->
417      * @generated
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      * <!-- begin-user-doc -->
446 	 * <!-- end-user-doc -->
447      * @generated
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      * <!-- begin-user-doc -->
470 	 * <!-- end-user-doc -->
471      * @generated
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 } //DtoPropertyImpl