1
2
3
4
5
6
7 package BusinessDomainDsl.impl;
8
9 import BusinessDomainDsl.BusinessDomainDslPackage;
10 import BusinessDomainDsl.BusinessDomainModel;
11 import BusinessDomainDsl.Enumeration;
12 import BusinessDomainDsl.EnumerationLiteral;
13
14 import java.util.Collection;
15
16 import org.eclipse.emf.common.notify.Notification;
17 import org.eclipse.emf.common.notify.NotificationChain;
18
19 import org.eclipse.emf.common.util.EList;
20
21 import org.eclipse.emf.ecore.EClass;
22 import org.eclipse.emf.ecore.InternalEObject;
23
24 import org.eclipse.emf.ecore.impl.ENotificationImpl;
25
26 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
27 import org.eclipse.emf.ecore.util.EcoreUtil;
28 import org.eclipse.emf.ecore.util.InternalEList;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 public class EnumerationImpl extends ModelElementImpl implements Enumeration {
45
46
47
48
49
50
51
52
53 protected EList<EnumerationLiteral> enumerationLiterals;
54
55
56
57
58
59
60 protected EnumerationImpl() {
61 super();
62 }
63
64
65
66
67
68
69 @Override
70 protected EClass eStaticClass() {
71 return BusinessDomainDslPackage.Literals.ENUMERATION;
72 }
73
74
75
76
77
78
79 public EList<EnumerationLiteral> getEnumerationLiterals() {
80 if (enumerationLiterals == null) {
81 enumerationLiterals = new EObjectContainmentWithInverseEList<EnumerationLiteral>(EnumerationLiteral.class, this, BusinessDomainDslPackage.ENUMERATION__ENUMERATION_LITERALS, BusinessDomainDslPackage.ENUMERATION_LITERAL__ENUMERATION);
82 }
83 return enumerationLiterals;
84 }
85
86
87
88
89
90
91 public BusinessDomainModel getModel() {
92 if (eContainerFeatureID() != BusinessDomainDslPackage.ENUMERATION__MODEL) return null;
93 return (BusinessDomainModel)eContainer();
94 }
95
96
97
98
99
100
101 public NotificationChain basicSetModel(BusinessDomainModel newModel, NotificationChain msgs) {
102 msgs = eBasicSetContainer((InternalEObject)newModel, BusinessDomainDslPackage.ENUMERATION__MODEL, msgs);
103 return msgs;
104 }
105
106
107
108
109
110
111 public void setModel(BusinessDomainModel newModel) {
112 if (newModel != eInternalContainer() || (eContainerFeatureID() != BusinessDomainDslPackage.ENUMERATION__MODEL && newModel != null)) {
113 if (EcoreUtil.isAncestor(this, newModel))
114 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
115 NotificationChain msgs = null;
116 if (eInternalContainer() != null)
117 msgs = eBasicRemoveFromContainer(msgs);
118 if (newModel != null)
119 msgs = ((InternalEObject)newModel).eInverseAdd(this, BusinessDomainDslPackage.BUSINESS_DOMAIN_MODEL__ENUMERATIONS, BusinessDomainModel.class, msgs);
120 msgs = basicSetModel(newModel, msgs);
121 if (msgs != null) msgs.dispatch();
122 }
123 else if (eNotificationRequired())
124 eNotify(new ENotificationImpl(this, Notification.SET, BusinessDomainDslPackage.ENUMERATION__MODEL, newModel, newModel));
125 }
126
127
128
129
130
131
132 @SuppressWarnings("unchecked")
133 @Override
134 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
135 switch (featureID) {
136 case BusinessDomainDslPackage.ENUMERATION__ENUMERATION_LITERALS:
137 return ((InternalEList<InternalEObject>)(InternalEList<?>)getEnumerationLiterals()).basicAdd(otherEnd, msgs);
138 case BusinessDomainDslPackage.ENUMERATION__MODEL:
139 if (eInternalContainer() != null)
140 msgs = eBasicRemoveFromContainer(msgs);
141 return basicSetModel((BusinessDomainModel)otherEnd, msgs);
142 }
143 return super.eInverseAdd(otherEnd, featureID, msgs);
144 }
145
146
147
148
149
150
151 @Override
152 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
153 switch (featureID) {
154 case BusinessDomainDslPackage.ENUMERATION__ENUMERATION_LITERALS:
155 return ((InternalEList<?>)getEnumerationLiterals()).basicRemove(otherEnd, msgs);
156 case BusinessDomainDslPackage.ENUMERATION__MODEL:
157 return basicSetModel(null, msgs);
158 }
159 return super.eInverseRemove(otherEnd, featureID, msgs);
160 }
161
162
163
164
165
166
167 @Override
168 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
169 switch (eContainerFeatureID()) {
170 case BusinessDomainDslPackage.ENUMERATION__MODEL:
171 return eInternalContainer().eInverseRemove(this, BusinessDomainDslPackage.BUSINESS_DOMAIN_MODEL__ENUMERATIONS, BusinessDomainModel.class, msgs);
172 }
173 return super.eBasicRemoveFromContainerFeature(msgs);
174 }
175
176
177
178
179
180
181 @Override
182 public Object eGet(int featureID, boolean resolve, boolean coreType) {
183 switch (featureID) {
184 case BusinessDomainDslPackage.ENUMERATION__ENUMERATION_LITERALS:
185 return getEnumerationLiterals();
186 case BusinessDomainDslPackage.ENUMERATION__MODEL:
187 return getModel();
188 }
189 return super.eGet(featureID, resolve, coreType);
190 }
191
192
193
194
195
196
197 @SuppressWarnings("unchecked")
198 @Override
199 public void eSet(int featureID, Object newValue) {
200 switch (featureID) {
201 case BusinessDomainDslPackage.ENUMERATION__ENUMERATION_LITERALS:
202 getEnumerationLiterals().clear();
203 getEnumerationLiterals().addAll((Collection<? extends EnumerationLiteral>)newValue);
204 return;
205 case BusinessDomainDslPackage.ENUMERATION__MODEL:
206 setModel((BusinessDomainModel)newValue);
207 return;
208 }
209 super.eSet(featureID, newValue);
210 }
211
212
213
214
215
216
217 @Override
218 public void eUnset(int featureID) {
219 switch (featureID) {
220 case BusinessDomainDslPackage.ENUMERATION__ENUMERATION_LITERALS:
221 getEnumerationLiterals().clear();
222 return;
223 case BusinessDomainDslPackage.ENUMERATION__MODEL:
224 setModel((BusinessDomainModel)null);
225 return;
226 }
227 super.eUnset(featureID);
228 }
229
230
231
232
233
234
235 @Override
236 public boolean eIsSet(int featureID) {
237 switch (featureID) {
238 case BusinessDomainDslPackage.ENUMERATION__ENUMERATION_LITERALS:
239 return enumerationLiterals != null && !enumerationLiterals.isEmpty();
240 case BusinessDomainDslPackage.ENUMERATION__MODEL:
241 return getModel() != null;
242 }
243 return super.eIsSet(featureID);
244 }
245
246 }