1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package EssentialOCL.impl; |
8 | |
9 | import EMOF.Parameter; |
10 | |
11 | import EMOF.impl.TypedElementImpl; |
12 | |
13 | import EssentialOCL.EssentialOCLPackage; |
14 | import EssentialOCL.LetExp; |
15 | import EssentialOCL.OclExpression; |
16 | import EssentialOCL.Variable; |
17 | |
18 | import org.eclipse.emf.common.notify.Notification; |
19 | import org.eclipse.emf.common.notify.NotificationChain; |
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.EcoreUtil; |
27 | |
28 | /** |
29 | * <!-- begin-user-doc --> |
30 | * An implementation of the model object '<em><b>Variable</b></em>'. |
31 | * <!-- end-user-doc --> |
32 | * <p> |
33 | * The following features are implemented: |
34 | * <ul> |
35 | * <li>{@link EssentialOCL.impl.VariableImpl#getInitExpression <em>Init Expression</em>}</li> |
36 | * <li>{@link EssentialOCL.impl.VariableImpl#getLetExp <em>Let Exp</em>}</li> |
37 | * <li>{@link EssentialOCL.impl.VariableImpl#getRepresentedParameter <em>Represented Parameter</em>}</li> |
38 | * </ul> |
39 | * </p> |
40 | * |
41 | * @generated |
42 | */ |
43 | public class VariableImpl extends TypedElementImpl implements Variable { |
44 | /** |
45 | * The cached value of the '{@link #getInitExpression() <em>Init Expression</em>}' containment reference. |
46 | * <!-- begin-user-doc --> |
47 | * <!-- end-user-doc --> |
48 | * @see #getInitExpression() |
49 | * @generated |
50 | * @ordered |
51 | */ |
52 | protected OclExpression initExpression; |
53 | |
54 | /** |
55 | * The cached value of the '{@link #getRepresentedParameter() <em>Represented Parameter</em>}' reference. |
56 | * <!-- begin-user-doc --> |
57 | * <!-- end-user-doc --> |
58 | * @see #getRepresentedParameter() |
59 | * @generated |
60 | * @ordered |
61 | */ |
62 | protected Parameter representedParameter; |
63 | |
64 | /** |
65 | * <!-- begin-user-doc --> |
66 | * <!-- end-user-doc --> |
67 | * @generated |
68 | */ |
69 | protected VariableImpl() { |
70 | super(); |
71 | } |
72 | |
73 | /** |
74 | * <!-- begin-user-doc --> |
75 | * <!-- end-user-doc --> |
76 | * @generated |
77 | */ |
78 | @Override |
79 | protected EClass eStaticClass() { |
80 | return EssentialOCLPackage.Literals.VARIABLE; |
81 | } |
82 | |
83 | /** |
84 | * <!-- begin-user-doc --> |
85 | * <!-- end-user-doc --> |
86 | * @generated |
87 | */ |
88 | public OclExpression getInitExpression() { |
89 | return initExpression; |
90 | } |
91 | |
92 | /** |
93 | * <!-- begin-user-doc --> |
94 | * <!-- end-user-doc --> |
95 | * @generated |
96 | */ |
97 | public NotificationChain basicSetInitExpression(OclExpression newInitExpression, NotificationChain msgs) { |
98 | OclExpression oldInitExpression = initExpression; |
99 | initExpression = newInitExpression; |
100 | if (eNotificationRequired()) { |
101 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.VARIABLE__INIT_EXPRESSION, oldInitExpression, newInitExpression); |
102 | if (msgs == null) msgs = notification; else msgs.add(notification); |
103 | } |
104 | return msgs; |
105 | } |
106 | |
107 | /** |
108 | * <!-- begin-user-doc --> |
109 | * <!-- end-user-doc --> |
110 | * @generated |
111 | */ |
112 | public void setInitExpression(OclExpression newInitExpression) { |
113 | if (newInitExpression != initExpression) { |
114 | NotificationChain msgs = null; |
115 | if (initExpression != null) |
116 | msgs = ((InternalEObject)initExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.VARIABLE__INIT_EXPRESSION, null, msgs); |
117 | if (newInitExpression != null) |
118 | msgs = ((InternalEObject)newInitExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EssentialOCLPackage.VARIABLE__INIT_EXPRESSION, null, msgs); |
119 | msgs = basicSetInitExpression(newInitExpression, msgs); |
120 | if (msgs != null) msgs.dispatch(); |
121 | } |
122 | else if (eNotificationRequired()) |
123 | eNotify(new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.VARIABLE__INIT_EXPRESSION, newInitExpression, newInitExpression)); |
124 | } |
125 | |
126 | /** |
127 | * <!-- begin-user-doc --> |
128 | * <!-- end-user-doc --> |
129 | * @generated |
130 | */ |
131 | public LetExp getLetExp() { |
132 | if (eContainerFeatureID() != EssentialOCLPackage.VARIABLE__LET_EXP) return null; |
133 | return (LetExp)eContainer(); |
134 | } |
135 | |
136 | /** |
137 | * <!-- begin-user-doc --> |
138 | * <!-- end-user-doc --> |
139 | * @generated |
140 | */ |
141 | public NotificationChain basicSetLetExp(LetExp newLetExp, NotificationChain msgs) { |
142 | msgs = eBasicSetContainer((InternalEObject)newLetExp, EssentialOCLPackage.VARIABLE__LET_EXP, msgs); |
143 | return msgs; |
144 | } |
145 | |
146 | /** |
147 | * <!-- begin-user-doc --> |
148 | * <!-- end-user-doc --> |
149 | * @generated |
150 | */ |
151 | public void setLetExp(LetExp newLetExp) { |
152 | if (newLetExp != eInternalContainer() || (eContainerFeatureID() != EssentialOCLPackage.VARIABLE__LET_EXP && newLetExp != null)) { |
153 | if (EcoreUtil.isAncestor(this, newLetExp)) |
154 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
155 | NotificationChain msgs = null; |
156 | if (eInternalContainer() != null) |
157 | msgs = eBasicRemoveFromContainer(msgs); |
158 | if (newLetExp != null) |
159 | msgs = ((InternalEObject)newLetExp).eInverseAdd(this, EssentialOCLPackage.LET_EXP__VARIABLE, LetExp.class, msgs); |
160 | msgs = basicSetLetExp(newLetExp, msgs); |
161 | if (msgs != null) msgs.dispatch(); |
162 | } |
163 | else if (eNotificationRequired()) |
164 | eNotify(new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.VARIABLE__LET_EXP, newLetExp, newLetExp)); |
165 | } |
166 | |
167 | /** |
168 | * <!-- begin-user-doc --> |
169 | * <!-- end-user-doc --> |
170 | * @generated |
171 | */ |
172 | public Parameter getRepresentedParameter() { |
173 | if (representedParameter != null && representedParameter.eIsProxy()) { |
174 | InternalEObject oldRepresentedParameter = (InternalEObject)representedParameter; |
175 | representedParameter = (Parameter)eResolveProxy(oldRepresentedParameter); |
176 | if (representedParameter != oldRepresentedParameter) { |
177 | if (eNotificationRequired()) |
178 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, EssentialOCLPackage.VARIABLE__REPRESENTED_PARAMETER, oldRepresentedParameter, representedParameter)); |
179 | } |
180 | } |
181 | return representedParameter; |
182 | } |
183 | |
184 | /** |
185 | * <!-- begin-user-doc --> |
186 | * <!-- end-user-doc --> |
187 | * @generated |
188 | */ |
189 | public Parameter basicGetRepresentedParameter() { |
190 | return representedParameter; |
191 | } |
192 | |
193 | /** |
194 | * <!-- begin-user-doc --> |
195 | * <!-- end-user-doc --> |
196 | * @generated |
197 | */ |
198 | public void setRepresentedParameter(Parameter newRepresentedParameter) { |
199 | Parameter oldRepresentedParameter = representedParameter; |
200 | representedParameter = newRepresentedParameter; |
201 | if (eNotificationRequired()) |
202 | eNotify(new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.VARIABLE__REPRESENTED_PARAMETER, oldRepresentedParameter, representedParameter)); |
203 | } |
204 | |
205 | /** |
206 | * <!-- begin-user-doc --> |
207 | * <!-- end-user-doc --> |
208 | * @generated |
209 | */ |
210 | @Override |
211 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
212 | switch (featureID) { |
213 | case EssentialOCLPackage.VARIABLE__LET_EXP: |
214 | if (eInternalContainer() != null) |
215 | msgs = eBasicRemoveFromContainer(msgs); |
216 | return basicSetLetExp((LetExp)otherEnd, msgs); |
217 | } |
218 | return super.eInverseAdd(otherEnd, featureID, msgs); |
219 | } |
220 | |
221 | /** |
222 | * <!-- begin-user-doc --> |
223 | * <!-- end-user-doc --> |
224 | * @generated |
225 | */ |
226 | @Override |
227 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
228 | switch (featureID) { |
229 | case EssentialOCLPackage.VARIABLE__INIT_EXPRESSION: |
230 | return basicSetInitExpression(null, msgs); |
231 | case EssentialOCLPackage.VARIABLE__LET_EXP: |
232 | return basicSetLetExp(null, msgs); |
233 | } |
234 | return super.eInverseRemove(otherEnd, featureID, msgs); |
235 | } |
236 | |
237 | /** |
238 | * <!-- begin-user-doc --> |
239 | * <!-- end-user-doc --> |
240 | * @generated |
241 | */ |
242 | @Override |
243 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
244 | switch (eContainerFeatureID()) { |
245 | case EssentialOCLPackage.VARIABLE__LET_EXP: |
246 | return eInternalContainer().eInverseRemove(this, EssentialOCLPackage.LET_EXP__VARIABLE, LetExp.class, msgs); |
247 | } |
248 | return super.eBasicRemoveFromContainerFeature(msgs); |
249 | } |
250 | |
251 | /** |
252 | * <!-- begin-user-doc --> |
253 | * <!-- end-user-doc --> |
254 | * @generated |
255 | */ |
256 | @Override |
257 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
258 | switch (featureID) { |
259 | case EssentialOCLPackage.VARIABLE__INIT_EXPRESSION: |
260 | return getInitExpression(); |
261 | case EssentialOCLPackage.VARIABLE__LET_EXP: |
262 | return getLetExp(); |
263 | case EssentialOCLPackage.VARIABLE__REPRESENTED_PARAMETER: |
264 | if (resolve) return getRepresentedParameter(); |
265 | return basicGetRepresentedParameter(); |
266 | } |
267 | return super.eGet(featureID, resolve, coreType); |
268 | } |
269 | |
270 | /** |
271 | * <!-- begin-user-doc --> |
272 | * <!-- end-user-doc --> |
273 | * @generated |
274 | */ |
275 | @Override |
276 | public void eSet(int featureID, Object newValue) { |
277 | switch (featureID) { |
278 | case EssentialOCLPackage.VARIABLE__INIT_EXPRESSION: |
279 | setInitExpression((OclExpression)newValue); |
280 | return; |
281 | case EssentialOCLPackage.VARIABLE__LET_EXP: |
282 | setLetExp((LetExp)newValue); |
283 | return; |
284 | case EssentialOCLPackage.VARIABLE__REPRESENTED_PARAMETER: |
285 | setRepresentedParameter((Parameter)newValue); |
286 | return; |
287 | } |
288 | super.eSet(featureID, newValue); |
289 | } |
290 | |
291 | /** |
292 | * <!-- begin-user-doc --> |
293 | * <!-- end-user-doc --> |
294 | * @generated |
295 | */ |
296 | @Override |
297 | public void eUnset(int featureID) { |
298 | switch (featureID) { |
299 | case EssentialOCLPackage.VARIABLE__INIT_EXPRESSION: |
300 | setInitExpression((OclExpression)null); |
301 | return; |
302 | case EssentialOCLPackage.VARIABLE__LET_EXP: |
303 | setLetExp((LetExp)null); |
304 | return; |
305 | case EssentialOCLPackage.VARIABLE__REPRESENTED_PARAMETER: |
306 | setRepresentedParameter((Parameter)null); |
307 | return; |
308 | } |
309 | super.eUnset(featureID); |
310 | } |
311 | |
312 | /** |
313 | * <!-- begin-user-doc --> |
314 | * <!-- end-user-doc --> |
315 | * @generated |
316 | */ |
317 | @Override |
318 | public boolean eIsSet(int featureID) { |
319 | switch (featureID) { |
320 | case EssentialOCLPackage.VARIABLE__INIT_EXPRESSION: |
321 | return initExpression != null; |
322 | case EssentialOCLPackage.VARIABLE__LET_EXP: |
323 | return getLetExp() != null; |
324 | case EssentialOCLPackage.VARIABLE__REPRESENTED_PARAMETER: |
325 | return representedParameter != null; |
326 | } |
327 | return super.eIsSet(featureID); |
328 | } |
329 | |
330 | } //VariableImpl |