001    /**
002     * <copyright>
003     * </copyright>
004     *
005     * $Id$
006     */
007    package com.hammurapi.eventbus.snapshot.impl;
008    
009    import com.hammurapi.eventbus.snapshot.Derivation;
010    import com.hammurapi.eventbus.snapshot.Event;
011    import com.hammurapi.eventbus.snapshot.Snapshot;
012    import com.hammurapi.eventbus.snapshot.SnapshotPackage;
013    
014    import java.util.Collection;
015    
016    import org.eclipse.emf.common.notify.Notification;
017    import org.eclipse.emf.common.notify.NotificationChain;
018    
019    import org.eclipse.emf.common.util.EList;
020    
021    import org.eclipse.emf.ecore.EClass;
022    import org.eclipse.emf.ecore.InternalEObject;
023    
024    import org.eclipse.emf.ecore.impl.ENotificationImpl;
025    import org.eclipse.emf.ecore.impl.EObjectImpl;
026    
027    import org.eclipse.emf.ecore.util.EObjectContainmentEList;
028    import org.eclipse.emf.ecore.util.EcoreUtil;
029    import org.eclipse.emf.ecore.util.InternalEList;
030    
031    /**
032     * <!-- begin-user-doc -->
033     * An implementation of the model object '<em><b>Event</b></em>'.
034     * <!-- end-user-doc -->
035     * <p>
036     * The following features are implemented:
037     * <ul>
038     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.EventImpl#getId <em>Id</em>}</li>
039     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.EventImpl#getName <em>Name</em>}</li>
040     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.EventImpl#getDetails <em>Details</em>}</li>
041     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.EventImpl#getSnapshot <em>Snapshot</em>}</li>
042     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.EventImpl#getDerivations <em>Derivations</em>}</li>
043     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.EventImpl#getPartRole <em>Part Role</em>}</li>
044     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.EventImpl#isDirectPost <em>Direct Post</em>}</li>
045     * </ul>
046     * </p>
047     *
048     * @generated
049     */
050    public class EventImpl extends EObjectImpl implements Event {
051            /**
052             * The default value of the '{@link #getId() <em>Id</em>}' attribute.
053             * <!-- begin-user-doc -->
054             * <!-- end-user-doc -->
055             * @see #getId()
056             * @generated
057             * @ordered
058             */
059            protected static final String ID_EDEFAULT = null;
060    
061            /**
062             * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
063             * <!-- begin-user-doc -->
064             * <!-- end-user-doc -->
065             * @see #getId()
066             * @generated
067             * @ordered
068             */
069            protected String id = ID_EDEFAULT;
070    
071            /**
072             * The default value of the '{@link #getName() <em>Name</em>}' attribute.
073             * <!-- begin-user-doc -->
074             * <!-- end-user-doc -->
075             * @see #getName()
076             * @generated
077             * @ordered
078             */
079            protected static final String NAME_EDEFAULT = null;
080    
081            /**
082             * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
083             * <!-- begin-user-doc -->
084             * <!-- end-user-doc -->
085             * @see #getName()
086             * @generated
087             * @ordered
088             */
089            protected String name = NAME_EDEFAULT;
090    
091            /**
092             * The default value of the '{@link #getDetails() <em>Details</em>}' attribute.
093             * <!-- begin-user-doc -->
094             * <!-- end-user-doc -->
095             * @see #getDetails()
096             * @generated
097             * @ordered
098             */
099            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