View Javadoc

1   /**
2    * (c) Mod4j and contributors
3    *
4    * $Id$
5    */
6   package org.mod4j.crossx.mm.crossx.impl;
7   
8   import java.util.Collection;
9   
10  import org.eclipse.emf.common.notify.Notification;
11  import org.eclipse.emf.common.notify.NotificationChain;
12  
13  import org.eclipse.emf.common.util.EList;
14  
15  import org.eclipse.emf.ecore.EClass;
16  import org.eclipse.emf.ecore.InternalEObject;
17  
18  import org.eclipse.emf.ecore.impl.ENotificationImpl;
19  import org.eclipse.emf.ecore.impl.EObjectImpl;
20  
21  import org.eclipse.emf.ecore.util.EObjectContainmentEList;
22  import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
23  import org.eclipse.emf.ecore.util.EcoreUtil;
24  import org.eclipse.emf.ecore.util.InternalEList;
25  
26  import org.mod4j.crossx.mm.crossx.CrossxPackage;
27  import org.mod4j.crossx.mm.crossx.ModelInfo;
28  import org.mod4j.crossx.mm.crossx.Symbol;
29  import org.mod4j.crossx.mm.crossx.SymbolProperty;
30  
31  /**
32   * <!-- begin-user-doc -->
33   * An implementation of the model object '<em><b>Symbol</b></em>'.
34   * <!-- end-user-doc -->
35   * <p>
36   * The following features are implemented:
37   * <ul>
38   *   <li>{@link org.mod4j.crossx.mm.crossx.impl.SymbolImpl#getName <em>Name</em>}</li>
39   *   <li>{@link org.mod4j.crossx.mm.crossx.impl.SymbolImpl#getType <em>Type</em>}</li>
40   *   <li>{@link org.mod4j.crossx.mm.crossx.impl.SymbolImpl#getProperties <em>Properties</em>}</li>
41   *   <li>{@link org.mod4j.crossx.mm.crossx.impl.SymbolImpl#getSubSymbols <em>Sub Symbols</em>}</li>
42   *   <li>{@link org.mod4j.crossx.mm.crossx.impl.SymbolImpl#getOwner <em>Owner</em>}</li>
43   *   <li>{@link org.mod4j.crossx.mm.crossx.impl.SymbolImpl#getParent <em>Parent</em>}</li>
44   * </ul>
45   * </p>
46   *
47   * @generated
48   */
49  public class SymbolImpl extends EObjectImpl implements Symbol {
50      /**
51       * The default value of the '{@link #getName() <em>Name</em>}' attribute.
52       * <!-- begin-user-doc -->
53       * <!-- end-user-doc -->
54       * @see #getName()
55       * @generated
56       * @ordered
57       */
58      protected static final String NAME_EDEFAULT = null;
59  
60      /**
61       * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
62       * <!-- begin-user-doc -->
63       * <!-- end-user-doc -->
64       * @see #getName()
65       * @generated
66       * @ordered
67       */
68      protected String name = NAME_EDEFAULT;
69  
70      /**
71       * The default value of the '{@link #getType() <em>Type</em>}' attribute.
72       * <!-- begin-user-doc -->
73       * <!-- end-user-doc -->
74       * @see #getType()
75       * @generated
76       * @ordered
77       */
78      protected static final String TYPE_EDEFAULT = null;
79  
80      /**
81       * The cached value of the '{@link #getType() <em>Type</em>}' attribute.
82       * <!-- begin-user-doc -->
83       * <!-- end-user-doc -->
84       * @see #getType()
85       * @generated
86       * @ordered
87       */
88      protected String type = TYPE_EDEFAULT;
89  
90      /**
91       * The cached value of the '{@link #getProperties() <em>Properties</em>}' containment reference list.
92       * <!-- begin-user-doc -->
93       * <!-- end-user-doc -->
94       * @see #getProperties()
95       * @generated
96       * @ordered
97       */
98      protected EList<SymbolProperty> properties;
99  
100     /**
101      * The cached value of the '{@link #getSubSymbols() <em>Sub Symbols</em>}' containment reference list.
102      * <!-- begin-user-doc -->
103      * <!-- end-user-doc -->
104      * @see #getSubSymbols()
105      * @generated
106      * @ordered
107      */
108     protected EList<Symbol> subSymbols;
109 
110     /**
111      * <!-- begin-user-doc -->
112      * <!-- end-user-doc -->
113      * @generated
114      */
115     protected SymbolImpl() {
116         super();
117     }
118 
119     /**
120      * <!-- begin-user-doc -->
121      * <!-- end-user-doc -->
122      * @generated
123      */
124     @Override
125     protected EClass eStaticClass() {
126         return CrossxPackage.Literals.SYMBOL;
127     }
128 
129     /**
130      * <!-- begin-user-doc -->
131      * <!-- end-user-doc -->
132      * @generated
133      */
134     public String getName() {
135         return name;
136     }
137 
138     /**
139      * <!-- begin-user-doc -->
140      * <!-- end-user-doc -->
141      * @generated
142      */
143     public void setName(String newName) {
144         String oldName = name;
145         name = newName;
146         if (eNotificationRequired())
147             eNotify(new ENotificationImpl(this, Notification.SET, CrossxPackage.SYMBOL__NAME, oldName, name));
148     }
149 
150     /**
151      * <!-- begin-user-doc -->
152      * <!-- end-user-doc -->
153      * @generated
154      */
155     public String getType() {
156         return type;
157     }
158 
159     /**
160      * <!-- begin-user-doc -->
161      * <!-- end-user-doc -->
162      * @generated
163      */
164     public void setType(String newType) {
165         String oldType = type;
166         type = newType;
167         if (eNotificationRequired())
168             eNotify(new ENotificationImpl(this, Notification.SET, CrossxPackage.SYMBOL__TYPE, oldType, type));
169     }
170 
171     /**
172      * <!-- begin-user-doc -->
173      * <!-- end-user-doc -->
174      * @generated
175      */
176     public EList<SymbolProperty> getProperties() {
177         if (properties == null) {
178             properties = new EObjectContainmentEList<SymbolProperty>(SymbolProperty.class, this, CrossxPackage.SYMBOL__PROPERTIES);
179         }
180         return properties;
181     }
182 
183     /**
184      * <!-- begin-user-doc -->
185      * <!-- end-user-doc -->
186      * @generated
187      */
188     public EList<Symbol> getSubSymbols() {
189         if (subSymbols == null) {
190             subSymbols = new EObjectContainmentWithInverseEList<Symbol>(Symbol.class, this, CrossxPackage.SYMBOL__SUB_SYMBOLS, CrossxPackage.SYMBOL__PARENT);
191         }
192         return subSymbols;
193     }
194 
195     /**
196      * <!-- begin-user-doc -->
197      * <!-- end-user-doc -->
198      * @generated
199      */
200     public ModelInfo getOwner() {
201         if (eContainerFeatureID() != CrossxPackage.SYMBOL__OWNER) return null;
202         return (ModelInfo)eContainer();
203     }
204 
205     /**
206      * <!-- begin-user-doc -->
207      * <!-- end-user-doc -->
208      * @generated
209      */
210     public NotificationChain basicSetOwner(ModelInfo newOwner, NotificationChain msgs) {
211         msgs = eBasicSetContainer((InternalEObject)newOwner, CrossxPackage.SYMBOL__OWNER, msgs);
212         return msgs;
213     }
214 
215     /**
216      * <!-- begin-user-doc -->
217      * <!-- end-user-doc -->
218      * @generated
219      */
220     public void setOwner(ModelInfo newOwner) {
221         if (newOwner != eInternalContainer() || (eContainerFeatureID() != CrossxPackage.SYMBOL__OWNER && newOwner != null)) {
222             if (EcoreUtil.isAncestor(this, newOwner))
223                 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
224             NotificationChain msgs = null;
225             if (eInternalContainer() != null)
226                 msgs = eBasicRemoveFromContainer(msgs);
227             if (newOwner != null)
228                 msgs = ((InternalEObject)newOwner).eInverseAdd(this, CrossxPackage.MODEL_INFO__SYMBOLS, ModelInfo.class, msgs);
229             msgs = basicSetOwner(newOwner, msgs);
230             if (msgs != null) msgs.dispatch();
231         }
232         else if (eNotificationRequired())
233             eNotify(new ENotificationImpl(this, Notification.SET, CrossxPackage.SYMBOL__OWNER, newOwner, newOwner));
234     }
235 
236     /**
237      * <!-- begin-user-doc -->
238      * <!-- end-user-doc -->
239      * @generated
240      */
241     public Symbol getParent() {
242         if (eContainerFeatureID() != CrossxPackage.SYMBOL__PARENT) return null;
243         return (Symbol)eContainer();
244     }
245 
246     /**
247      * <!-- begin-user-doc -->
248      * <!-- end-user-doc -->
249      * @generated
250      */
251     public NotificationChain basicSetParent(Symbol newParent, NotificationChain msgs) {
252         msgs = eBasicSetContainer((InternalEObject)newParent, CrossxPackage.SYMBOL__PARENT, msgs);
253         return msgs;
254     }
255 
256     /**
257      * <!-- begin-user-doc -->
258      * <!-- end-user-doc -->
259      * @generated
260      */
261     public void setParent(Symbol newParent) {
262         if (newParent != eInternalContainer() || (eContainerFeatureID() != CrossxPackage.SYMBOL__PARENT && newParent != null)) {
263             if (EcoreUtil.isAncestor(this, newParent))
264                 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
265             NotificationChain msgs = null;
266             if (eInternalContainer() != null)
267                 msgs = eBasicRemoveFromContainer(msgs);
268             if (newParent != null)
269                 msgs = ((InternalEObject)newParent).eInverseAdd(this, CrossxPackage.SYMBOL__SUB_SYMBOLS, Symbol.class, msgs);
270             msgs = basicSetParent(newParent, msgs);
271             if (msgs != null) msgs.dispatch();
272         }
273         else if (eNotificationRequired())
274             eNotify(new ENotificationImpl(this, Notification.SET, CrossxPackage.SYMBOL__PARENT, newParent, newParent));
275     }
276 
277     /**
278      * <!-- begin-user-doc -->
279      * <!-- end-user-doc -->
280      * @generated
281      */
282     @SuppressWarnings("unchecked")
283     @Override
284     public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
285         switch (featureID) {
286             case CrossxPackage.SYMBOL__SUB_SYMBOLS:
287                 return ((InternalEList<InternalEObject>)(InternalEList<?>)getSubSymbols()).basicAdd(otherEnd, msgs);
288             case CrossxPackage.SYMBOL__OWNER:
289                 if (eInternalContainer() != null)
290                     msgs = eBasicRemoveFromContainer(msgs);
291                 return basicSetOwner((ModelInfo)otherEnd, msgs);
292             case CrossxPackage.SYMBOL__PARENT:
293                 if (eInternalContainer() != null)
294                     msgs = eBasicRemoveFromContainer(msgs);
295                 return basicSetParent((Symbol)otherEnd, msgs);
296         }
297         return super.eInverseAdd(otherEnd, featureID, msgs);
298     }
299 
300     /**
301      * <!-- begin-user-doc -->
302      * <!-- end-user-doc -->
303      * @generated
304      */
305     @Override
306     public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
307         switch (featureID) {
308             case CrossxPackage.SYMBOL__PROPERTIES:
309                 return ((InternalEList<?>)getProperties()).basicRemove(otherEnd, msgs);
310             case CrossxPackage.SYMBOL__SUB_SYMBOLS:
311                 return ((InternalEList<?>)getSubSymbols()).basicRemove(otherEnd, msgs);
312             case CrossxPackage.SYMBOL__OWNER:
313                 return basicSetOwner(null, msgs);
314             case CrossxPackage.SYMBOL__PARENT:
315                 return basicSetParent(null, msgs);
316         }
317         return super.eInverseRemove(otherEnd, featureID, msgs);
318     }
319 
320     /**
321      * <!-- begin-user-doc -->
322      * <!-- end-user-doc -->
323      * @generated
324      */
325     @Override
326     public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
327         switch (eContainerFeatureID()) {
328             case CrossxPackage.SYMBOL__OWNER:
329                 return eInternalContainer().eInverseRemove(this, CrossxPackage.MODEL_INFO__SYMBOLS, ModelInfo.class, msgs);
330             case CrossxPackage.SYMBOL__PARENT:
331                 return eInternalContainer().eInverseRemove(this, CrossxPackage.SYMBOL__SUB_SYMBOLS, Symbol.class, msgs);
332         }
333         return super.eBasicRemoveFromContainerFeature(msgs);
334     }
335 
336     /**
337      * <!-- begin-user-doc -->
338      * <!-- end-user-doc -->
339      * @generated
340      */
341     @Override
342     public Object eGet(int featureID, boolean resolve, boolean coreType) {
343         switch (featureID) {
344             case CrossxPackage.SYMBOL__NAME:
345                 return getName();
346             case CrossxPackage.SYMBOL__TYPE:
347                 return getType();
348             case CrossxPackage.SYMBOL__PROPERTIES:
349                 return getProperties();
350             case CrossxPackage.SYMBOL__SUB_SYMBOLS:
351                 return getSubSymbols();
352             case CrossxPackage.SYMBOL__OWNER:
353                 return getOwner();
354             case CrossxPackage.SYMBOL__PARENT:
355                 return getParent();
356         }
357         return super.eGet(featureID, resolve, coreType);
358     }
359 
360     /**
361      * <!-- begin-user-doc -->
362      * <!-- end-user-doc -->
363      * @generated
364      */
365     @SuppressWarnings("unchecked")
366     @Override
367     public void eSet(int featureID, Object newValue) {
368         switch (featureID) {
369             case CrossxPackage.SYMBOL__NAME:
370                 setName((String)newValue);
371                 return;
372             case CrossxPackage.SYMBOL__TYPE:
373                 setType((String)newValue);
374                 return;
375             case CrossxPackage.SYMBOL__PROPERTIES:
376                 getProperties().clear();
377                 getProperties().addAll((Collection<? extends SymbolProperty>)newValue);
378                 return;
379             case CrossxPackage.SYMBOL__SUB_SYMBOLS:
380                 getSubSymbols().clear();
381                 getSubSymbols().addAll((Collection<? extends Symbol>)newValue);
382                 return;
383             case CrossxPackage.SYMBOL__OWNER:
384                 setOwner((ModelInfo)newValue);
385                 return;
386             case CrossxPackage.SYMBOL__PARENT:
387                 setParent((Symbol)newValue);
388                 return;
389         }
390         super.eSet(featureID, newValue);
391     }
392 
393     /**
394      * <!-- begin-user-doc -->
395      * <!-- end-user-doc -->
396      * @generated
397      */
398     @Override
399     public void eUnset(int featureID) {
400         switch (featureID) {
401             case CrossxPackage.SYMBOL__NAME:
402                 setName(NAME_EDEFAULT);
403                 return;
404             case CrossxPackage.SYMBOL__TYPE:
405                 setType(TYPE_EDEFAULT);
406                 return;
407             case CrossxPackage.SYMBOL__PROPERTIES:
408                 getProperties().clear();
409                 return;
410             case CrossxPackage.SYMBOL__SUB_SYMBOLS:
411                 getSubSymbols().clear();
412                 return;
413             case CrossxPackage.SYMBOL__OWNER:
414                 setOwner((ModelInfo)null);
415                 return;
416             case CrossxPackage.SYMBOL__PARENT:
417                 setParent((Symbol)null);
418                 return;
419         }
420         super.eUnset(featureID);
421     }
422 
423     /**
424      * <!-- begin-user-doc -->
425      * <!-- end-user-doc -->
426      * @generated
427      */
428     @Override
429     public boolean eIsSet(int featureID) {
430         switch (featureID) {
431             case CrossxPackage.SYMBOL__NAME:
432                 return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
433             case CrossxPackage.SYMBOL__TYPE:
434                 return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
435             case CrossxPackage.SYMBOL__PROPERTIES:
436                 return properties != null && !properties.isEmpty();
437             case CrossxPackage.SYMBOL__SUB_SYMBOLS:
438                 return subSymbols != null && !subSymbols.isEmpty();
439             case CrossxPackage.SYMBOL__OWNER:
440                 return getOwner() != null;
441             case CrossxPackage.SYMBOL__PARENT:
442                 return getParent() != null;
443         }
444         return super.eIsSet(featureID);
445     }
446 
447     /**
448      * <!-- begin-user-doc -->
449      * <!-- end-user-doc -->
450      * @generated
451      */
452     @Override
453     public String toString() {
454         if (eIsProxy()) return super.toString();
455 
456         StringBuffer result = new StringBuffer(super.toString());
457         result.append(" (name: ");
458         result.append(name);
459         result.append(", type: ");
460         result.append(type);
461         result.append(')');
462         return result.toString();
463     }
464 
465 } //SymbolImpl