View Javadoc

1   /**
2    * <copyright>
3    * </copyright>
4    *
5    * $Id$
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   * <!-- begin-user-doc -->
27   * An implementation of the model object '<em><b>Parameter</b></em>'.
28   * <!-- end-user-doc -->
29   * <p>
30   * The following features are implemented:
31   * <ul>
32   *   <li>{@link org.mod4j.dsl.service.mm.ServiceDsl.impl.ParameterImpl#getType <em>Type</em>}</li>
33   *   <li>{@link org.mod4j.dsl.service.mm.ServiceDsl.impl.ParameterImpl#getMethod <em>Method</em>}</li>
34   *   <li>{@link org.mod4j.dsl.service.mm.ServiceDsl.impl.ParameterImpl#getCollection <em>Collection</em>}</li>
35   * </ul>
36   * </p>
37   *
38   * @generated
39   */
40  public class ParameterImpl extends ModelElementImpl implements Parameter {
41      /**
42       * The cached value of the '{@link #getType() <em>Type</em>}' reference.
43       * <!-- begin-user-doc -->
44       * <!-- end-user-doc -->
45       * @see #getType()
46       * @generated
47       * @ordered
48       */
49      protected DtoReference type;
50  
51      /**
52       * The default value of the '{@link #getCollection() <em>Collection</em>}' attribute.
53       * <!-- begin-user-doc -->
54       * <!-- end-user-doc -->
55       * @see #getCollection()
56       * @generated
57       * @ordered
58       */
59      protected static final CollectionType COLLECTION_EDEFAULT = CollectionType.SINGLE;
60      /**
61       * The cached value of the '{@link #getCollection() <em>Collection</em>}' attribute.
62       * <!-- begin-user-doc -->
63       * <!-- end-user-doc -->
64       * @see #getCollection()
65       * @generated
66       * @ordered
67       */
68      protected CollectionType collection = COLLECTION_EDEFAULT;
69  
70      /**
71       * <!-- begin-user-doc -->
72       * <!-- end-user-doc -->
73       * @generated
74       */
75      protected ParameterImpl() {
76          super();
77      }
78  
79      /**
80       * <!-- begin-user-doc -->
81       * <!-- end-user-doc -->
82       * @generated
83       */
84      @Override
85      protected EClass eStaticClass() {
86          return ServiceDslPackage.Literals.PARAMETER;
87      }
88  
89      /**
90       * <!-- begin-user-doc -->
91       * <!-- end-user-doc -->
92       * @generated
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      * <!-- begin-user-doc -->
108      * <!-- end-user-doc -->
109      * @generated
110      */
111     public DtoReference basicGetType() {
112         return type;
113     }
114 
115     /**
116      * <!-- begin-user-doc -->
117      * <!-- end-user-doc -->
118      * @generated
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      * <!-- begin-user-doc -->
129      * <!-- end-user-doc -->
130      * @generated
131      */
132     public CustomMethod getMethod() {
133         if (eContainerFeatureID() != ServiceDslPackage.PARAMETER__METHOD) return null;
134         return (CustomMethod)eContainer();
135     }
136 
137     /**
138      * <!-- begin-user-doc -->
139      * <!-- end-user-doc -->
140      * @generated
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      * <!-- begin-user-doc -->
149      * <!-- end-user-doc -->
150      * @generated
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      * <!-- begin-user-doc -->
170      * <!-- end-user-doc -->
171      * @generated
172      */
173     public CollectionType getCollection() {
174         return collection;
175     }
176 
177     /**
178      * <!-- begin-user-doc -->
179      * <!-- end-user-doc -->
180      * @generated
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      * <!-- begin-user-doc -->
191      * <!-- end-user-doc -->
192      * @generated
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      * <!-- begin-user-doc -->
207      * <!-- end-user-doc -->
208      * @generated
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      * <!-- begin-user-doc -->
221      * <!-- end-user-doc -->
222      * @generated
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      * <!-- begin-user-doc -->
235      * <!-- end-user-doc -->
236      * @generated
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      * <!-- begin-user-doc -->
254      * <!-- end-user-doc -->
255      * @generated
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      * <!-- begin-user-doc -->
275      * <!-- end-user-doc -->
276      * @generated
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      * <!-- begin-user-doc -->
296      * <!-- end-user-doc -->
297      * @generated
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      * <!-- begin-user-doc -->
314      * <!-- end-user-doc -->
315      * @generated
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 } //ParameterImpl