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