1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package QVTRelation.impl; |
8 | |
9 | import EssentialOCL.Variable; |
10 | |
11 | import QVTBase.Pattern; |
12 | |
13 | import QVTBase.impl.RuleImpl; |
14 | |
15 | import QVTRelation.QVTRelationPackage; |
16 | import QVTRelation.Relation; |
17 | import QVTRelation.RelationImplementation; |
18 | |
19 | import java.util.Collection; |
20 | |
21 | import org.eclipse.emf.common.notify.Notification; |
22 | import org.eclipse.emf.common.notify.NotificationChain; |
23 | |
24 | import org.eclipse.emf.common.util.EList; |
25 | |
26 | import org.eclipse.emf.ecore.EClass; |
27 | import org.eclipse.emf.ecore.InternalEObject; |
28 | |
29 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
30 | |
31 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
32 | import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; |
33 | import org.eclipse.emf.ecore.util.InternalEList; |
34 | |
35 | /** |
36 | * <!-- begin-user-doc --> |
37 | * An implementation of the model object '<em><b>Relation</b></em>'. |
38 | * <!-- end-user-doc --> |
39 | * <p> |
40 | * The following features are implemented: |
41 | * <ul> |
42 | * <li>{@link QVTRelation.impl.RelationImpl#getIsTopLevel <em>Is Top Level</em>}</li> |
43 | * <li>{@link QVTRelation.impl.RelationImpl#getOperationalImpl <em>Operational Impl</em>}</li> |
44 | * <li>{@link QVTRelation.impl.RelationImpl#getVariable <em>Variable</em>}</li> |
45 | * <li>{@link QVTRelation.impl.RelationImpl#getWhen <em>When</em>}</li> |
46 | * <li>{@link QVTRelation.impl.RelationImpl#getWhere <em>Where</em>}</li> |
47 | * </ul> |
48 | * </p> |
49 | * |
50 | * @generated |
51 | */ |
52 | public class RelationImpl extends RuleImpl implements Relation { |
53 | /** |
54 | * The default value of the '{@link #getIsTopLevel() <em>Is Top Level</em>}' attribute. |
55 | * <!-- begin-user-doc --> |
56 | * <!-- end-user-doc --> |
57 | * @see #getIsTopLevel() |
58 | * @generated |
59 | * @ordered |
60 | */ |
61 | protected static final Boolean IS_TOP_LEVEL_EDEFAULT = null; |
62 | |
63 | /** |
64 | * The cached value of the '{@link #getIsTopLevel() <em>Is Top Level</em>}' attribute. |
65 | * <!-- begin-user-doc --> |
66 | * <!-- end-user-doc --> |
67 | * @see #getIsTopLevel() |
68 | * @generated |
69 | * @ordered |
70 | */ |
71 | protected Boolean isTopLevel = IS_TOP_LEVEL_EDEFAULT; |
72 | |
73 | /** |
74 | * The cached value of the '{@link #getOperationalImpl() <em>Operational Impl</em>}' containment reference list. |
75 | * <!-- begin-user-doc --> |
76 | * <!-- end-user-doc --> |
77 | * @see #getOperationalImpl() |
78 | * @generated |
79 | * @ordered |
80 | */ |
81 | protected EList<RelationImplementation> operationalImpl; |
82 | |
83 | /** |
84 | * The cached value of the '{@link #getVariable() <em>Variable</em>}' containment reference list. |
85 | * <!-- begin-user-doc --> |
86 | * <!-- end-user-doc --> |
87 | * @see #getVariable() |
88 | * @generated |
89 | * @ordered |
90 | */ |
91 | protected EList<Variable> variable; |
92 | |
93 | /** |
94 | * The cached value of the '{@link #getWhen() <em>When</em>}' containment reference. |
95 | * <!-- begin-user-doc --> |
96 | * <!-- end-user-doc --> |
97 | * @see #getWhen() |
98 | * @generated |
99 | * @ordered |
100 | */ |
101 | protected Pattern when; |
102 | |
103 | /** |
104 | * The cached value of the '{@link #getWhere() <em>Where</em>}' containment reference. |
105 | * <!-- begin-user-doc --> |
106 | * <!-- end-user-doc --> |
107 | * @see #getWhere() |
108 | * @generated |
109 | * @ordered |
110 | */ |
111 | protected Pattern where; |
112 | |
113 | /** |
114 | * <!-- begin-user-doc --> |
115 | * <!-- end-user-doc --> |
116 | * @generated |
117 | */ |
118 | protected RelationImpl() { |
119 | super(); |
120 | } |
121 | |
122 | /** |
123 | * <!-- begin-user-doc --> |
124 | * <!-- end-user-doc --> |
125 | * @generated |
126 | */ |
127 | @Override |
128 | protected EClass eStaticClass() { |
129 | return QVTRelationPackage.Literals.RELATION; |
130 | } |
131 | |
132 | /** |
133 | * <!-- begin-user-doc --> |
134 | * <!-- end-user-doc --> |
135 | * @generated |
136 | */ |
137 | public Boolean getIsTopLevel() { |
138 | return isTopLevel; |
139 | } |
140 | |
141 | /** |
142 | * <!-- begin-user-doc --> |
143 | * <!-- end-user-doc --> |
144 | * @generated |
145 | */ |
146 | public void setIsTopLevel(Boolean newIsTopLevel) { |
147 | Boolean oldIsTopLevel = isTopLevel; |
148 | isTopLevel = newIsTopLevel; |
149 | if (eNotificationRequired()) |
150 | eNotify(new ENotificationImpl(this, Notification.SET, QVTRelationPackage.RELATION__IS_TOP_LEVEL, oldIsTopLevel, isTopLevel)); |
151 | } |
152 | |
153 | /** |
154 | * <!-- begin-user-doc --> |
155 | * <!-- end-user-doc --> |
156 | * @generated |
157 | */ |
158 | public EList<RelationImplementation> getOperationalImpl() { |
159 | if (operationalImpl == null) { |
160 | operationalImpl = new EObjectContainmentWithInverseEList<RelationImplementation>(RelationImplementation.class, this, QVTRelationPackage.RELATION__OPERATIONAL_IMPL, QVTRelationPackage.RELATION_IMPLEMENTATION__RELATION); |
161 | } |
162 | return operationalImpl; |
163 | } |
164 | |
165 | /** |
166 | * <!-- begin-user-doc --> |
167 | * <!-- end-user-doc --> |
168 | * @generated |
169 | */ |
170 | public EList<Variable> getVariable() { |
171 | if (variable == null) { |
172 | variable = new EObjectContainmentEList<Variable>(Variable.class, this, QVTRelationPackage.RELATION__VARIABLE); |
173 | } |
174 | return variable; |
175 | } |
176 | |
177 | /** |
178 | * <!-- begin-user-doc --> |
179 | * <!-- end-user-doc --> |
180 | * @generated |
181 | */ |
182 | public Pattern getWhen() { |
183 | return when; |
184 | } |
185 | |
186 | /** |
187 | * <!-- begin-user-doc --> |
188 | * <!-- end-user-doc --> |
189 | * @generated |
190 | */ |
191 | public NotificationChain basicSetWhen(Pattern newWhen, NotificationChain msgs) { |
192 | Pattern oldWhen = when; |
193 | when = newWhen; |
194 | if (eNotificationRequired()) { |
195 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, QVTRelationPackage.RELATION__WHEN, oldWhen, newWhen); |
196 | if (msgs == null) msgs = notification; else msgs.add(notification); |
197 | } |
198 | return msgs; |
199 | } |
200 | |
201 | /** |
202 | * <!-- begin-user-doc --> |
203 | * <!-- end-user-doc --> |
204 | * @generated |
205 | */ |
206 | public void setWhen(Pattern newWhen) { |
207 | if (newWhen != when) { |
208 | NotificationChain msgs = null; |
209 | if (when != null) |
210 | msgs = ((InternalEObject)when).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - QVTRelationPackage.RELATION__WHEN, null, msgs); |
211 | if (newWhen != null) |
212 | msgs = ((InternalEObject)newWhen).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - QVTRelationPackage.RELATION__WHEN, null, msgs); |
213 | msgs = basicSetWhen(newWhen, msgs); |
214 | if (msgs != null) msgs.dispatch(); |
215 | } |
216 | else if (eNotificationRequired()) |
217 | eNotify(new ENotificationImpl(this, Notification.SET, QVTRelationPackage.RELATION__WHEN, newWhen, newWhen)); |
218 | } |
219 | |
220 | /** |
221 | * <!-- begin-user-doc --> |
222 | * <!-- end-user-doc --> |
223 | * @generated |
224 | */ |
225 | public Pattern getWhere() { |
226 | return where; |
227 | } |
228 | |
229 | /** |
230 | * <!-- begin-user-doc --> |
231 | * <!-- end-user-doc --> |
232 | * @generated |
233 | */ |
234 | public NotificationChain basicSetWhere(Pattern newWhere, NotificationChain msgs) { |
235 | Pattern oldWhere = where; |
236 | where = newWhere; |
237 | if (eNotificationRequired()) { |
238 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, QVTRelationPackage.RELATION__WHERE, oldWhere, newWhere); |
239 | if (msgs == null) msgs = notification; else msgs.add(notification); |
240 | } |
241 | return msgs; |
242 | } |
243 | |
244 | /** |
245 | * <!-- begin-user-doc --> |
246 | * <!-- end-user-doc --> |
247 | * @generated |
248 | */ |
249 | public void setWhere(Pattern newWhere) { |
250 | if (newWhere != where) { |
251 | NotificationChain msgs = null; |
252 | if (where != null) |
253 | msgs = ((InternalEObject)where).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - QVTRelationPackage.RELATION__WHERE, null, msgs); |
254 | if (newWhere != null) |
255 | msgs = ((InternalEObject)newWhere).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - QVTRelationPackage.RELATION__WHERE, null, msgs); |
256 | msgs = basicSetWhere(newWhere, msgs); |
257 | if (msgs != null) msgs.dispatch(); |
258 | } |
259 | else if (eNotificationRequired()) |
260 | eNotify(new ENotificationImpl(this, Notification.SET, QVTRelationPackage.RELATION__WHERE, newWhere, newWhere)); |
261 | } |
262 | |
263 | /** |
264 | * <!-- begin-user-doc --> |
265 | * <!-- end-user-doc --> |
266 | * @generated |
267 | */ |
268 | @SuppressWarnings("unchecked") |
269 | @Override |
270 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
271 | switch (featureID) { |
272 | case QVTRelationPackage.RELATION__OPERATIONAL_IMPL: |
273 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getOperationalImpl()).basicAdd(otherEnd, msgs); |
274 | } |
275 | return super.eInverseAdd(otherEnd, featureID, msgs); |
276 | } |
277 | |
278 | /** |
279 | * <!-- begin-user-doc --> |
280 | * <!-- end-user-doc --> |
281 | * @generated |
282 | */ |
283 | @Override |
284 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
285 | switch (featureID) { |
286 | case QVTRelationPackage.RELATION__OPERATIONAL_IMPL: |
287 | return ((InternalEList<?>)getOperationalImpl()).basicRemove(otherEnd, msgs); |
288 | case QVTRelationPackage.RELATION__VARIABLE: |
289 | return ((InternalEList<?>)getVariable()).basicRemove(otherEnd, msgs); |
290 | case QVTRelationPackage.RELATION__WHEN: |
291 | return basicSetWhen(null, msgs); |
292 | case QVTRelationPackage.RELATION__WHERE: |
293 | return basicSetWhere(null, msgs); |
294 | } |
295 | return super.eInverseRemove(otherEnd, featureID, msgs); |
296 | } |
297 | |
298 | /** |
299 | * <!-- begin-user-doc --> |
300 | * <!-- end-user-doc --> |
301 | * @generated |
302 | */ |
303 | @Override |
304 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
305 | switch (featureID) { |
306 | case QVTRelationPackage.RELATION__IS_TOP_LEVEL: |
307 | return getIsTopLevel(); |
308 | case QVTRelationPackage.RELATION__OPERATIONAL_IMPL: |
309 | return getOperationalImpl(); |
310 | case QVTRelationPackage.RELATION__VARIABLE: |
311 | return getVariable(); |
312 | case QVTRelationPackage.RELATION__WHEN: |
313 | return getWhen(); |
314 | case QVTRelationPackage.RELATION__WHERE: |
315 | return getWhere(); |
316 | } |
317 | return super.eGet(featureID, resolve, coreType); |
318 | } |
319 | |
320 | /** |
321 | * <!-- begin-user-doc --> |
322 | * <!-- end-user-doc --> |
323 | * @generated |
324 | */ |
325 | @SuppressWarnings("unchecked") |
326 | @Override |
327 | public void eSet(int featureID, Object newValue) { |
328 | switch (featureID) { |
329 | case QVTRelationPackage.RELATION__IS_TOP_LEVEL: |
330 | setIsTopLevel((Boolean)newValue); |
331 | return; |
332 | case QVTRelationPackage.RELATION__OPERATIONAL_IMPL: |
333 | getOperationalImpl().clear(); |
334 | getOperationalImpl().addAll((Collection<? extends RelationImplementation>)newValue); |
335 | return; |
336 | case QVTRelationPackage.RELATION__VARIABLE: |
337 | getVariable().clear(); |
338 | getVariable().addAll((Collection<? extends Variable>)newValue); |
339 | return; |
340 | case QVTRelationPackage.RELATION__WHEN: |
341 | setWhen((Pattern)newValue); |
342 | return; |
343 | case QVTRelationPackage.RELATION__WHERE: |
344 | setWhere((Pattern)newValue); |
345 | return; |
346 | } |
347 | super.eSet(featureID, newValue); |
348 | } |
349 | |
350 | /** |
351 | * <!-- begin-user-doc --> |
352 | * <!-- end-user-doc --> |
353 | * @generated |
354 | */ |
355 | @Override |
356 | public void eUnset(int featureID) { |
357 | switch (featureID) { |
358 | case QVTRelationPackage.RELATION__IS_TOP_LEVEL: |
359 | setIsTopLevel(IS_TOP_LEVEL_EDEFAULT); |
360 | return; |
361 | case QVTRelationPackage.RELATION__OPERATIONAL_IMPL: |
362 | getOperationalImpl().clear(); |
363 | return; |
364 | case QVTRelationPackage.RELATION__VARIABLE: |
365 | getVariable().clear(); |
366 | return; |
367 | case QVTRelationPackage.RELATION__WHEN: |
368 | setWhen((Pattern)null); |
369 | return; |
370 | case QVTRelationPackage.RELATION__WHERE: |
371 | setWhere((Pattern)null); |
372 | return; |
373 | } |
374 | super.eUnset(featureID); |
375 | } |
376 | |
377 | /** |
378 | * <!-- begin-user-doc --> |
379 | * <!-- end-user-doc --> |
380 | * @generated |
381 | */ |
382 | @Override |
383 | public boolean eIsSet(int featureID) { |
384 | switch (featureID) { |
385 | case QVTRelationPackage.RELATION__IS_TOP_LEVEL: |
386 | return IS_TOP_LEVEL_EDEFAULT == null ? isTopLevel != null : !IS_TOP_LEVEL_EDEFAULT.equals(isTopLevel); |
387 | case QVTRelationPackage.RELATION__OPERATIONAL_IMPL: |
388 | return operationalImpl != null && !operationalImpl.isEmpty(); |
389 | case QVTRelationPackage.RELATION__VARIABLE: |
390 | return variable != null && !variable.isEmpty(); |
391 | case QVTRelationPackage.RELATION__WHEN: |
392 | return when != null; |
393 | case QVTRelationPackage.RELATION__WHERE: |
394 | return where != null; |
395 | } |
396 | return super.eIsSet(featureID); |
397 | } |
398 | |
399 | /** |
400 | * <!-- begin-user-doc --> |
401 | * <!-- end-user-doc --> |
402 | * @generated |
403 | */ |
404 | @Override |
405 | public String toString() { |
406 | if (eIsProxy()) return super.toString(); |
407 | |
408 | StringBuffer result = new StringBuffer(super.toString()); |
409 | result.append(" (isTopLevel: "); |
410 | result.append(isTopLevel); |
411 | result.append(')'); |
412 | return result.toString(); |
413 | } |
414 | |
415 | } //RelationImpl |