1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package EMOF.impl; |
8 | |
9 | import EMOF.EMOFPackage; |
10 | import EMOF.MultiplicityElement; |
11 | import EMOF.Operation; |
12 | import EMOF.Parameter; |
13 | import EMOF.Type; |
14 | |
15 | import java.util.Collection; |
16 | |
17 | import org.eclipse.emf.common.notify.Notification; |
18 | import org.eclipse.emf.common.notify.NotificationChain; |
19 | |
20 | import org.eclipse.emf.common.util.EList; |
21 | |
22 | import org.eclipse.emf.ecore.EClass; |
23 | import org.eclipse.emf.ecore.InternalEObject; |
24 | |
25 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
26 | |
27 | import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; |
28 | import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
29 | import org.eclipse.emf.ecore.util.EcoreUtil; |
30 | import org.eclipse.emf.ecore.util.InternalEList; |
31 | |
32 | /** |
33 | * <!-- begin-user-doc --> |
34 | * An implementation of the model object '<em><b>Operation</b></em>'. |
35 | * <!-- end-user-doc --> |
36 | * <p> |
37 | * The following features are implemented: |
38 | * <ul> |
39 | * <li>{@link EMOF.impl.OperationImpl#getIsOrdered <em>Is Ordered</em>}</li> |
40 | * <li>{@link EMOF.impl.OperationImpl#getIsUnique <em>Is Unique</em>}</li> |
41 | * <li>{@link EMOF.impl.OperationImpl#getLower <em>Lower</em>}</li> |
42 | * <li>{@link EMOF.impl.OperationImpl#getUpper <em>Upper</em>}</li> |
43 | * <li>{@link EMOF.impl.OperationImpl#getClass_ <em>Class</em>}</li> |
44 | * <li>{@link EMOF.impl.OperationImpl#getOwnedParameter <em>Owned Parameter</em>}</li> |
45 | * <li>{@link EMOF.impl.OperationImpl#getRaisedException <em>Raised Exception</em>}</li> |
46 | * </ul> |
47 | * </p> |
48 | * |
49 | * @generated |
50 | */ |
51 | public class OperationImpl extends TypedElementImpl implements Operation { |
52 | /** |
53 | * The default value of the '{@link #getIsOrdered() <em>Is Ordered</em>}' attribute. |
54 | * <!-- begin-user-doc --> |
55 | * <!-- end-user-doc --> |
56 | * @see #getIsOrdered() |
57 | * @generated |
58 | * @ordered |
59 | */ |
60 | protected static final Boolean IS_ORDERED_EDEFAULT = Boolean.FALSE; |
61 | |
62 | /** |
63 | * The cached value of the '{@link #getIsOrdered() <em>Is Ordered</em>}' attribute. |
64 | * <!-- begin-user-doc --> |
65 | * <!-- end-user-doc --> |
66 | * @see #getIsOrdered() |
67 | * @generated |
68 | * @ordered |
69 | */ |
70 | protected Boolean isOrdered = IS_ORDERED_EDEFAULT; |
71 | |
72 | /** |
73 | * The default value of the '{@link #getIsUnique() <em>Is Unique</em>}' attribute. |
74 | * <!-- begin-user-doc --> |
75 | * <!-- end-user-doc --> |
76 | * @see #getIsUnique() |
77 | * @generated |
78 | * @ordered |
79 | */ |
80 | protected static final Boolean IS_UNIQUE_EDEFAULT = Boolean.TRUE; |
81 | |
82 | /** |
83 | * The cached value of the '{@link #getIsUnique() <em>Is Unique</em>}' attribute. |
84 | * <!-- begin-user-doc --> |
85 | * <!-- end-user-doc --> |
86 | * @see #getIsUnique() |
87 | * @generated |
88 | * @ordered |
89 | */ |
90 | protected Boolean isUnique = IS_UNIQUE_EDEFAULT; |
91 | |
92 | /** |
93 | * The default value of the '{@link #getLower() <em>Lower</em>}' attribute. |
94 | * <!-- begin-user-doc --> |
95 | * <!-- end-user-doc --> |
96 | * @see #getLower() |
97 | * @generated |
98 | * @ordered |
99 | */ |
100 | protected static final Integer LOWER_EDEFAULT = new Integer(1); |
101 | |
102 | /** |
103 | * The cached value of the '{@link #getLower() <em>Lower</em>}' attribute. |
104 | * <!-- begin-user-doc --> |
105 | * <!-- end-user-doc --> |
106 | * @see #getLower() |
107 | * @generated |
108 | * @ordered |
109 | */ |
110 | protected Integer lower = LOWER_EDEFAULT; |
111 | |
112 | /** |
113 | * The default value of the '{@link #getUpper() <em>Upper</em>}' attribute. |
114 | * <!-- begin-user-doc --> |
115 | * <!-- end-user-doc --> |
116 | * @see #getUpper() |
117 | * @generated |
118 | * @ordered |
119 | */ |
120 | protected static final Integer UPPER_EDEFAULT = new Integer(1); |
121 | |
122 | /** |
123 | * The cached value of the '{@link #getUpper() <em>Upper</em>}' attribute. |
124 | * <!-- begin-user-doc --> |
125 | * <!-- end-user-doc --> |
126 | * @see #getUpper() |
127 | * @generated |
128 | * @ordered |
129 | */ |
130 | protected Integer upper = UPPER_EDEFAULT; |
131 | |
132 | /** |
133 | * The cached value of the '{@link #getOwnedParameter() <em>Owned Parameter</em>}' containment reference list. |
134 | * <!-- begin-user-doc --> |
135 | * <!-- end-user-doc --> |
136 | * @see #getOwnedParameter() |
137 | * @generated |
138 | * @ordered |
139 | */ |
140 | protected EList<Parameter> ownedParameter; |
141 | |
142 | /** |
143 | * The cached value of the '{@link #getRaisedException() <em>Raised Exception</em>}' reference list. |
144 | * <!-- begin-user-doc --> |
145 | * <!-- end-user-doc --> |
146 | * @see #getRaisedException() |
147 | * @generated |
148 | * @ordered |
149 | */ |
150 | protected EList<Type> raisedException; |
151 | |
152 | /** |
153 | * <!-- begin-user-doc --> |
154 | * <!-- end-user-doc --> |
155 | * @generated |
156 | */ |
157 | protected OperationImpl() { |
158 | super(); |
159 | } |
160 | |
161 | /** |
162 | * <!-- begin-user-doc --> |
163 | * <!-- end-user-doc --> |
164 | * @generated |
165 | */ |
166 | @Override |
167 | protected EClass eStaticClass() { |
168 | return EMOFPackage.Literals.OPERATION; |
169 | } |
170 | |
171 | /** |
172 | * <!-- begin-user-doc --> |
173 | * <!-- end-user-doc --> |
174 | * @generated |
175 | */ |
176 | public Boolean getIsOrdered() { |
177 | return isOrdered; |
178 | } |
179 | |
180 | /** |
181 | * <!-- begin-user-doc --> |
182 | * <!-- end-user-doc --> |
183 | * @generated |
184 | */ |
185 | public void setIsOrdered(Boolean newIsOrdered) { |
186 | Boolean oldIsOrdered = isOrdered; |
187 | isOrdered = newIsOrdered; |
188 | if (eNotificationRequired()) |
189 | eNotify(new ENotificationImpl(this, Notification.SET, EMOFPackage.OPERATION__IS_ORDERED, oldIsOrdered, isOrdered)); |
190 | } |
191 | |
192 | /** |
193 | * <!-- begin-user-doc --> |
194 | * <!-- end-user-doc --> |
195 | * @generated |
196 | */ |
197 | public Boolean getIsUnique() { |
198 | return isUnique; |
199 | } |
200 | |
201 | /** |
202 | * <!-- begin-user-doc --> |
203 | * <!-- end-user-doc --> |
204 | * @generated |
205 | */ |
206 | public void setIsUnique(Boolean newIsUnique) { |
207 | Boolean oldIsUnique = isUnique; |
208 | isUnique = newIsUnique; |
209 | if (eNotificationRequired()) |
210 | eNotify(new ENotificationImpl(this, Notification.SET, EMOFPackage.OPERATION__IS_UNIQUE, oldIsUnique, isUnique)); |
211 | } |
212 | |
213 | /** |
214 | * <!-- begin-user-doc --> |
215 | * <!-- end-user-doc --> |
216 | * @generated |
217 | */ |
218 | public Integer getLower() { |
219 | return lower; |
220 | } |
221 | |
222 | /** |
223 | * <!-- begin-user-doc --> |
224 | * <!-- end-user-doc --> |
225 | * @generated |
226 | */ |
227 | public void setLower(Integer newLower) { |
228 | Integer oldLower = lower; |
229 | lower = newLower; |
230 | if (eNotificationRequired()) |
231 | eNotify(new ENotificationImpl(this, Notification.SET, EMOFPackage.OPERATION__LOWER, oldLower, lower)); |
232 | } |
233 | |
234 | /** |
235 | * <!-- begin-user-doc --> |
236 | * <!-- end-user-doc --> |
237 | * @generated |
238 | */ |
239 | public Integer getUpper() { |
240 | return upper; |
241 | } |
242 | |
243 | /** |
244 | * <!-- begin-user-doc --> |
245 | * <!-- end-user-doc --> |
246 | * @generated |
247 | */ |
248 | public void setUpper(Integer newUpper) { |
249 | Integer oldUpper = upper; |
250 | upper = newUpper; |
251 | if (eNotificationRequired()) |
252 | eNotify(new ENotificationImpl(this, Notification.SET, EMOFPackage.OPERATION__UPPER, oldUpper, upper)); |
253 | } |
254 | |
255 | /** |
256 | * <!-- begin-user-doc --> |
257 | * <!-- end-user-doc --> |
258 | * @generated |
259 | */ |
260 | public EMOF.Class getClass_() { |
261 | if (eContainerFeatureID() != EMOFPackage.OPERATION__CLASS) return null; |
262 | return (EMOF.Class)eContainer(); |
263 | } |
264 | |
265 | /** |
266 | * <!-- begin-user-doc --> |
267 | * <!-- end-user-doc --> |
268 | * @generated |
269 | */ |
270 | public NotificationChain basicSetClass(EMOF.Class newClass, NotificationChain msgs) { |
271 | msgs = eBasicSetContainer((InternalEObject)newClass, EMOFPackage.OPERATION__CLASS, msgs); |
272 | return msgs; |
273 | } |
274 | |
275 | /** |
276 | * <!-- begin-user-doc --> |
277 | * <!-- end-user-doc --> |
278 | * @generated |
279 | */ |
280 | public void setClass(EMOF.Class newClass) { |
281 | if (newClass != eInternalContainer() || (eContainerFeatureID() != EMOFPackage.OPERATION__CLASS && newClass != null)) { |
282 | if (EcoreUtil.isAncestor(this, newClass)) |
283 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
284 | NotificationChain msgs = null; |
285 | if (eInternalContainer() != null) |
286 | msgs = eBasicRemoveFromContainer(msgs); |
287 | if (newClass != null) |
288 | msgs = ((InternalEObject)newClass).eInverseAdd(this, EMOFPackage.CLASS__OWNED_OPERATION, EMOF.Class.class, msgs); |
289 | msgs = basicSetClass(newClass, msgs); |
290 | if (msgs != null) msgs.dispatch(); |
291 | } |
292 | else if (eNotificationRequired()) |
293 | eNotify(new ENotificationImpl(this, Notification.SET, EMOFPackage.OPERATION__CLASS, newClass, newClass)); |
294 | } |
295 | |
296 | /** |
297 | * <!-- begin-user-doc --> |
298 | * <!-- end-user-doc --> |
299 | * @generated |
300 | */ |
301 | public EList<Parameter> getOwnedParameter() { |
302 | if (ownedParameter == null) { |
303 | ownedParameter = new EObjectContainmentWithInverseEList<Parameter>(Parameter.class, this, EMOFPackage.OPERATION__OWNED_PARAMETER, EMOFPackage.PARAMETER__OPERATION); |
304 | } |
305 | return ownedParameter; |
306 | } |
307 | |
308 | /** |
309 | * <!-- begin-user-doc --> |
310 | * <!-- end-user-doc --> |
311 | * @generated |
312 | */ |
313 | public EList<Type> getRaisedException() { |
314 | if (raisedException == null) { |
315 | raisedException = new EObjectResolvingEList<Type>(Type.class, this, EMOFPackage.OPERATION__RAISED_EXCEPTION); |
316 | } |
317 | return raisedException; |
318 | } |
319 | |
320 | /** |
321 | * <!-- begin-user-doc --> |
322 | * <!-- end-user-doc --> |
323 | * @generated |
324 | */ |
325 | @SuppressWarnings("unchecked") |
326 | @Override |
327 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
328 | switch (featureID) { |
329 | case EMOFPackage.OPERATION__CLASS: |
330 | if (eInternalContainer() != null) |
331 | msgs = eBasicRemoveFromContainer(msgs); |
332 | return basicSetClass((EMOF.Class)otherEnd, msgs); |
333 | case EMOFPackage.OPERATION__OWNED_PARAMETER: |
334 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedParameter()).basicAdd(otherEnd, msgs); |
335 | } |
336 | return super.eInverseAdd(otherEnd, featureID, msgs); |
337 | } |
338 | |
339 | /** |
340 | * <!-- begin-user-doc --> |
341 | * <!-- end-user-doc --> |
342 | * @generated |
343 | */ |
344 | @Override |
345 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
346 | switch (featureID) { |
347 | case EMOFPackage.OPERATION__CLASS: |
348 | return basicSetClass(null, msgs); |
349 | case EMOFPackage.OPERATION__OWNED_PARAMETER: |
350 | return ((InternalEList<?>)getOwnedParameter()).basicRemove(otherEnd, msgs); |
351 | } |
352 | return super.eInverseRemove(otherEnd, featureID, msgs); |
353 | } |
354 | |
355 | /** |
356 | * <!-- begin-user-doc --> |
357 | * <!-- end-user-doc --> |
358 | * @generated |
359 | */ |
360 | @Override |
361 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
362 | switch (eContainerFeatureID()) { |
363 | case EMOFPackage.OPERATION__CLASS: |
364 | return eInternalContainer().eInverseRemove(this, EMOFPackage.CLASS__OWNED_OPERATION, EMOF.Class.class, msgs); |
365 | } |
366 | return super.eBasicRemoveFromContainerFeature(msgs); |
367 | } |
368 | |
369 | /** |
370 | * <!-- begin-user-doc --> |
371 | * <!-- end-user-doc --> |
372 | * @generated |
373 | */ |
374 | @Override |
375 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
376 | switch (featureID) { |
377 | case EMOFPackage.OPERATION__IS_ORDERED: |
378 | return getIsOrdered(); |
379 | case EMOFPackage.OPERATION__IS_UNIQUE: |
380 | return getIsUnique(); |
381 | case EMOFPackage.OPERATION__LOWER: |
382 | return getLower(); |
383 | case EMOFPackage.OPERATION__UPPER: |
384 | return getUpper(); |
385 | case EMOFPackage.OPERATION__CLASS: |
386 | return getClass_(); |
387 | case EMOFPackage.OPERATION__OWNED_PARAMETER: |
388 | return getOwnedParameter(); |
389 | case EMOFPackage.OPERATION__RAISED_EXCEPTION: |
390 | return getRaisedException(); |
391 | } |
392 | return super.eGet(featureID, resolve, coreType); |
393 | } |
394 | |
395 | /** |
396 | * <!-- begin-user-doc --> |
397 | * <!-- end-user-doc --> |
398 | * @generated |
399 | */ |
400 | @SuppressWarnings("unchecked") |
401 | @Override |
402 | public void eSet(int featureID, Object newValue) { |
403 | switch (featureID) { |
404 | case EMOFPackage.OPERATION__IS_ORDERED: |
405 | setIsOrdered((Boolean)newValue); |
406 | return; |
407 | case EMOFPackage.OPERATION__IS_UNIQUE: |
408 | setIsUnique((Boolean)newValue); |
409 | return; |
410 | case EMOFPackage.OPERATION__LOWER: |
411 | setLower((Integer)newValue); |
412 | return; |
413 | case EMOFPackage.OPERATION__UPPER: |
414 | setUpper((Integer)newValue); |
415 | return; |
416 | case EMOFPackage.OPERATION__CLASS: |
417 | setClass((EMOF.Class)newValue); |
418 | return; |
419 | case EMOFPackage.OPERATION__OWNED_PARAMETER: |
420 | getOwnedParameter().clear(); |
421 | getOwnedParameter().addAll((Collection<? extends Parameter>)newValue); |
422 | return; |
423 | case EMOFPackage.OPERATION__RAISED_EXCEPTION: |
424 | getRaisedException().clear(); |
425 | getRaisedException().addAll((Collection<? extends Type>)newValue); |
426 | return; |
427 | } |
428 | super.eSet(featureID, newValue); |
429 | } |
430 | |
431 | /** |
432 | * <!-- begin-user-doc --> |
433 | * <!-- end-user-doc --> |
434 | * @generated |
435 | */ |
436 | @Override |
437 | public void eUnset(int featureID) { |
438 | switch (featureID) { |
439 | case EMOFPackage.OPERATION__IS_ORDERED: |
440 | setIsOrdered(IS_ORDERED_EDEFAULT); |
441 | return; |
442 | case EMOFPackage.OPERATION__IS_UNIQUE: |
443 | setIsUnique(IS_UNIQUE_EDEFAULT); |
444 | return; |
445 | case EMOFPackage.OPERATION__LOWER: |
446 | setLower(LOWER_EDEFAULT); |
447 | return; |
448 | case EMOFPackage.OPERATION__UPPER: |
449 | setUpper(UPPER_EDEFAULT); |
450 | return; |
451 | case EMOFPackage.OPERATION__CLASS: |
452 | setClass((EMOF.Class)null); |
453 | return; |
454 | case EMOFPackage.OPERATION__OWNED_PARAMETER: |
455 | getOwnedParameter().clear(); |
456 | return; |
457 | case EMOFPackage.OPERATION__RAISED_EXCEPTION: |
458 | getRaisedException().clear(); |
459 | return; |
460 | } |
461 | super.eUnset(featureID); |
462 | } |
463 | |
464 | /** |
465 | * <!-- begin-user-doc --> |
466 | * <!-- end-user-doc --> |
467 | * @generated |
468 | */ |
469 | @Override |
470 | public boolean eIsSet(int featureID) { |
471 | switch (featureID) { |
472 | case EMOFPackage.OPERATION__IS_ORDERED: |
473 | return IS_ORDERED_EDEFAULT == null ? isOrdered != null : !IS_ORDERED_EDEFAULT.equals(isOrdered); |
474 | case EMOFPackage.OPERATION__IS_UNIQUE: |
475 | return IS_UNIQUE_EDEFAULT == null ? isUnique != null : !IS_UNIQUE_EDEFAULT.equals(isUnique); |
476 | case EMOFPackage.OPERATION__LOWER: |
477 | return LOWER_EDEFAULT == null ? lower != null : !LOWER_EDEFAULT.equals(lower); |
478 | case EMOFPackage.OPERATION__UPPER: |
479 | return UPPER_EDEFAULT == null ? upper != null : !UPPER_EDEFAULT.equals(upper); |
480 | case EMOFPackage.OPERATION__CLASS: |
481 | return getClass_() != null; |
482 | case EMOFPackage.OPERATION__OWNED_PARAMETER: |
483 | return ownedParameter != null && !ownedParameter.isEmpty(); |
484 | case EMOFPackage.OPERATION__RAISED_EXCEPTION: |
485 | return raisedException != null && !raisedException.isEmpty(); |
486 | } |
487 | return super.eIsSet(featureID); |
488 | } |
489 | |
490 | /** |
491 | * <!-- begin-user-doc --> |
492 | * <!-- end-user-doc --> |
493 | * @generated |
494 | */ |
495 | @Override |
496 | public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { |
497 | if (baseClass == MultiplicityElement.class) { |
498 | switch (derivedFeatureID) { |
499 | case EMOFPackage.OPERATION__IS_ORDERED: return EMOFPackage.MULTIPLICITY_ELEMENT__IS_ORDERED; |
500 | case EMOFPackage.OPERATION__IS_UNIQUE: return EMOFPackage.MULTIPLICITY_ELEMENT__IS_UNIQUE; |
501 | case EMOFPackage.OPERATION__LOWER: return EMOFPackage.MULTIPLICITY_ELEMENT__LOWER; |
502 | case EMOFPackage.OPERATION__UPPER: return EMOFPackage.MULTIPLICITY_ELEMENT__UPPER; |
503 | default: return -1; |
504 | } |
505 | } |
506 | return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); |
507 | } |
508 | |
509 | /** |
510 | * <!-- begin-user-doc --> |
511 | * <!-- end-user-doc --> |
512 | * @generated |
513 | */ |
514 | @Override |
515 | public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { |
516 | if (baseClass == MultiplicityElement.class) { |
517 | switch (baseFeatureID) { |
518 | case EMOFPackage.MULTIPLICITY_ELEMENT__IS_ORDERED: return EMOFPackage.OPERATION__IS_ORDERED; |
519 | case EMOFPackage.MULTIPLICITY_ELEMENT__IS_UNIQUE: return EMOFPackage.OPERATION__IS_UNIQUE; |
520 | case EMOFPackage.MULTIPLICITY_ELEMENT__LOWER: return EMOFPackage.OPERATION__LOWER; |
521 | case EMOFPackage.MULTIPLICITY_ELEMENT__UPPER: return EMOFPackage.OPERATION__UPPER; |
522 | default: return -1; |
523 | } |
524 | } |
525 | return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
526 | } |
527 | |
528 | /** |
529 | * <!-- begin-user-doc --> |
530 | * <!-- end-user-doc --> |
531 | * @generated |
532 | */ |
533 | @Override |
534 | public String toString() { |
535 | if (eIsProxy()) return super.toString(); |
536 | |
537 | StringBuffer result = new StringBuffer(super.toString()); |
538 | result.append(" (isOrdered: "); |
539 | result.append(isOrdered); |
540 | result.append(", isUnique: "); |
541 | result.append(isUnique); |
542 | result.append(", lower: "); |
543 | result.append(lower); |
544 | result.append(", upper: "); |
545 | result.append(upper); |
546 | result.append(')'); |
547 | return result.toString(); |
548 | } |
549 | |
550 | } //OperationImpl |