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