View Javadoc

1   /**
2    * <copyright>
3    * </copyright>
4    *
5    * $Id$
6    */
7   package BusinessDomainDsl.impl;
8   
9   import BusinessDomainDsl.BusinessDomainDslPackage;
10  import BusinessDomainDsl.Enumeration;
11  import BusinessDomainDsl.EnumerationLiteral;
12  
13  import org.eclipse.emf.common.notify.Notification;
14  import org.eclipse.emf.common.notify.NotificationChain;
15  
16  import org.eclipse.emf.ecore.EClass;
17  import org.eclipse.emf.ecore.InternalEObject;
18  
19  import org.eclipse.emf.ecore.impl.ENotificationImpl;
20  
21  import org.eclipse.emf.ecore.util.EcoreUtil;
22  
23  /**
24   * <!-- begin-user-doc -->
25   * An implementation of the model object '<em><b>Enumeration Literal</b></em>'.
26   * <!-- end-user-doc -->
27   * <p>
28   * The following features are implemented:
29   * <ul>
30   *   <li>{@link BusinessDomainDsl.impl.EnumerationLiteralImpl#getPersistedValue <em>Persisted Value</em>}</li>
31   *   <li>{@link BusinessDomainDsl.impl.EnumerationLiteralImpl#getEnumeration <em>Enumeration</em>}</li>
32   * </ul>
33   * </p>
34   *
35   * @generated
36   */
37  public class EnumerationLiteralImpl extends ModelElementImpl implements EnumerationLiteral {
38  	/**
39       * The default value of the '{@link #getPersistedValue() <em>Persisted Value</em>}' attribute.
40       * <!-- begin-user-doc -->
41  	 * <!-- end-user-doc -->
42       * @see #getPersistedValue()
43       * @generated
44       * @ordered
45       */
46  	protected static final int PERSISTED_VALUE_EDEFAULT = 0;
47  
48  	/**
49       * The cached value of the '{@link #getPersistedValue() <em>Persisted Value</em>}' attribute.
50       * <!-- begin-user-doc -->
51  	 * <!-- end-user-doc -->
52       * @see #getPersistedValue()
53       * @generated
54       * @ordered
55       */
56  	protected int persistedValue = PERSISTED_VALUE_EDEFAULT;
57  
58  	/**
59       * <!-- begin-user-doc -->
60  	 * <!-- end-user-doc -->
61       * @generated
62       */
63  	protected EnumerationLiteralImpl() {
64          super();
65      }
66  
67  	/**
68       * <!-- begin-user-doc -->
69  	 * <!-- end-user-doc -->
70       * @generated
71       */
72  	@Override
73  	protected EClass eStaticClass() {
74          return BusinessDomainDslPackage.Literals.ENUMERATION_LITERAL;
75      }
76  
77  	/**
78       * <!-- begin-user-doc -->
79  	 * <!-- end-user-doc -->
80       * @generated
81       */
82  	public int getPersistedValue() {
83          return persistedValue;
84      }
85  
86  	/**
87       * <!-- begin-user-doc -->
88  	 * <!-- end-user-doc -->
89       * @generated
90       */
91  	public void setPersistedValue(int newPersistedValue) {
92          int oldPersistedValue = persistedValue;
93          persistedValue = newPersistedValue;
94          if (eNotificationRequired())
95              eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.ENUMERATION_LITERAL__PERSISTED_VALUE, oldPersistedValue, persistedValue));
96      }
97  
98  	/**
99       * <!-- begin-user-doc -->
100 	 * <!-- end-user-doc -->
101      * @generated
102      */
103 	public Enumeration getEnumeration() {
104         if (eContainerFeatureID() != BusinessDomainDslPackage.ENUMERATION_LITERAL__ENUMERATION) return null;
105         return (Enumeration)eContainer();
106     }
107 
108 	/**
109      * <!-- begin-user-doc -->
110 	 * <!-- end-user-doc -->
111      * @generated
112      */
113 	public NotificationChain basicSetEnumeration(Enumeration newEnumeration, NotificationChain msgs) {
114         msgs = eBasicSetContainer((InternalEObject)newEnumeration, BusinessDomainDslPackage.ENUMERATION_LITERAL__ENUMERATION, msgs);
115         return msgs;
116     }
117 
118 	/**
119      * <!-- begin-user-doc -->
120 	 * <!-- end-user-doc -->
121      * @generated
122      */
123 	public void setEnumeration(Enumeration newEnumeration) {
124         if (newEnumeration != eInternalContainer() || (eContainerFeatureID() != BusinessDomainDslPackage.ENUMERATION_LITERAL__ENUMERATION && newEnumeration != null)) {
125             if (EcoreUtil.isAncestor(this, newEnumeration))
126                 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
127             NotificationChain msgs = null;
128             if (eInternalContainer() != null)
129                 msgs = eBasicRemoveFromContainer(msgs);
130             if (newEnumeration != null)
131                 msgs = ((InternalEObject)newEnumeration).eInverseAdd(this, BusinessDomainDslPackage.ENUMERATION__ENUMERATION_LITERALS, Enumeration.class, msgs);
132             msgs = basicSetEnumeration(newEnumeration, msgs);
133             if (msgs != null) msgs.dispatch();
134         }
135         else if (eNotificationRequired())
136             eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.ENUMERATION_LITERAL__ENUMERATION, newEnumeration, newEnumeration));
137     }
138 
139 	/**
140      * <!-- begin-user-doc -->
141 	 * <!-- end-user-doc -->
142      * @generated
143      */
144 	@Override
145 	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
146         switch (featureID) {
147             case BusinessDomainDslPackage.ENUMERATION_LITERAL__ENUMERATION:
148                 if (eInternalContainer() != null)
149                     msgs = eBasicRemoveFromContainer(msgs);
150                 return basicSetEnumeration((Enumeration)otherEnd, msgs);
151         }
152         return super.eInverseAdd(otherEnd, featureID, msgs);
153     }
154 
155 	/**
156      * <!-- begin-user-doc -->
157 	 * <!-- end-user-doc -->
158      * @generated
159      */
160 	@Override
161 	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
162         switch (featureID) {
163             case BusinessDomainDslPackage.ENUMERATION_LITERAL__ENUMERATION:
164                 return basicSetEnumeration(null, msgs);
165         }
166         return super.eInverseRemove(otherEnd, featureID, msgs);
167     }
168 
169 	/**
170      * <!-- begin-user-doc -->
171 	 * <!-- end-user-doc -->
172      * @generated
173      */
174 	@Override
175 	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
176         switch (eContainerFeatureID()) {
177             case BusinessDomainDslPackage.ENUMERATION_LITERAL__ENUMERATION:
178                 return eInternalContainer().eInverseRemove(this, BusinessDomainDslPackage.ENUMERATION__ENUMERATION_LITERALS, Enumeration.class, msgs);
179         }
180         return super.eBasicRemoveFromContainerFeature(msgs);
181     }
182 
183 	/**
184      * <!-- begin-user-doc -->
185 	 * <!-- end-user-doc -->
186      * @generated
187      */
188 	@Override
189 	public Object eGet(int featureID, boolean resolve, boolean coreType) {
190         switch (featureID) {
191             case BusinessDomainDslPackage.ENUMERATION_LITERAL__PERSISTED_VALUE:
192                 return getPersistedValue();
193             case BusinessDomainDslPackage.ENUMERATION_LITERAL__ENUMERATION:
194                 return getEnumeration();
195         }
196         return super.eGet(featureID, resolve, coreType);
197     }
198 
199 	/**
200      * <!-- begin-user-doc -->
201 	 * <!-- end-user-doc -->
202      * @generated
203      */
204 	@Override
205 	public void eSet(int featureID, Object newValue) {
206         switch (featureID) {
207             case BusinessDomainDslPackage.ENUMERATION_LITERAL__PERSISTED_VALUE:
208                 setPersistedValue((Integer)newValue);
209                 return;
210             case BusinessDomainDslPackage.ENUMERATION_LITERAL__ENUMERATION:
211                 setEnumeration((Enumeration)newValue);
212                 return;
213         }
214         super.eSet(featureID, newValue);
215     }
216 
217 	/**
218      * <!-- begin-user-doc -->
219 	 * <!-- end-user-doc -->
220      * @generated
221      */
222 	@Override
223 	public void eUnset(int featureID) {
224         switch (featureID) {
225             case BusinessDomainDslPackage.ENUMERATION_LITERAL__PERSISTED_VALUE:
226                 setPersistedValue(PERSISTED_VALUE_EDEFAULT);
227                 return;
228             case BusinessDomainDslPackage.ENUMERATION_LITERAL__ENUMERATION:
229                 setEnumeration((Enumeration)null);
230                 return;
231         }
232         super.eUnset(featureID);
233     }
234 
235 	/**
236      * <!-- begin-user-doc -->
237 	 * <!-- end-user-doc -->
238      * @generated
239      */
240 	@Override
241 	public boolean eIsSet(int featureID) {
242         switch (featureID) {
243             case BusinessDomainDslPackage.ENUMERATION_LITERAL__PERSISTED_VALUE:
244                 return persistedValue != PERSISTED_VALUE_EDEFAULT;
245             case BusinessDomainDslPackage.ENUMERATION_LITERAL__ENUMERATION:
246                 return getEnumeration() != null;
247         }
248         return super.eIsSet(featureID);
249     }
250 
251 	/**
252      * <!-- begin-user-doc -->
253 	 * <!-- end-user-doc -->
254      * @generated
255      */
256 	@Override
257 	public String toString() {
258         if (eIsProxy()) return super.toString();
259 
260         StringBuffer result = new StringBuffer(super.toString());
261         result.append(" (persistedValue: ");
262         result.append(persistedValue);
263         result.append(')');
264         return result.toString();
265     }
266 
267 } //EnumerationLiteralImpl