001    /**
002     * <copyright>
003     * </copyright>
004     *
005     * $Id$
006     */
007    package com.hammurapi.eventbus.snapshot.impl;
008    
009    import com.hammurapi.eventbus.snapshot.JoinInput;
010    import com.hammurapi.eventbus.snapshot.JoinNode;
011    import com.hammurapi.eventbus.snapshot.Snapshot;
012    import com.hammurapi.eventbus.snapshot.SnapshotPackage;
013    
014    import org.eclipse.emf.common.notify.Notification;
015    
016    import org.eclipse.emf.common.notify.NotificationChain;
017    import org.eclipse.emf.ecore.EClass;
018    import org.eclipse.emf.ecore.InternalEObject;
019    
020    import org.eclipse.emf.ecore.impl.ENotificationImpl;
021    import org.eclipse.emf.ecore.impl.EObjectImpl;
022    import org.eclipse.emf.ecore.util.EcoreUtil;
023    
024    /**
025     * <!-- begin-user-doc -->
026     * An implementation of the model object '<em><b>Join Input</b></em>'.
027     * <!-- end-user-doc -->
028     * <p>
029     * The following features are implemented:
030     * <ul>
031     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.JoinInputImpl#getId <em>Id</em>}</li>
032     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.JoinInputImpl#getName <em>Name</em>}</li>
033     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.JoinInputImpl#getDetails <em>Details</em>}</li>
034     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.JoinInputImpl#getSnapshot <em>Snapshot</em>}</li>
035     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.JoinInputImpl#getIndex <em>Index</em>}</li>
036     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.JoinInputImpl#getJoinNode <em>Join Node</em>}</li>
037     * </ul>
038     * </p>
039     *
040     * @generated
041     */
042    public class JoinInputImpl extends EObjectImpl implements JoinInput {
043            /**
044             * The default value of the '{@link #getId() <em>Id</em>}' attribute.
045             * <!-- begin-user-doc -->
046             * <!-- end-user-doc -->
047             * @see #getId()
048             * @generated
049             * @ordered
050             */
051            protected static final String ID_EDEFAULT = null;
052    
053            /**
054             * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
055             * <!-- begin-user-doc -->
056             * <!-- end-user-doc -->
057             * @see #getId()
058             * @generated
059             * @ordered
060             */
061            protected String id = ID_EDEFAULT;
062    
063            /**
064             * The default value of the '{@link #getName() <em>Name</em>}' attribute.
065             * <!-- begin-user-doc -->
066             * <!-- end-user-doc -->
067             * @see #getName()
068             * @generated
069             * @ordered
070             */
071            protected static final String NAME_EDEFAULT = null;
072    
073            /**
074             * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
075             * <!-- begin-user-doc -->
076             * <!-- end-user-doc -->
077             * @see #getName()
078             * @generated
079             * @ordered
080             */
081            protected String name = NAME_EDEFAULT;
082    
083            /**
084             * The default value of the '{@link #getDetails() <em>Details</em>}' attribute.
085             * <!-- begin-user-doc -->
086             * <!-- end-user-doc -->
087             * @see #getDetails()
088             * @generated
089             * @ordered
090             */
091            protected static final String DETAILS_EDEFAULT = null;
092    
093            /**
094             * The cached value of the '{@link #getDetails() <em>Details</em>}' attribute.
095             * <!-- begin-user-doc -->
096             * <!-- end-user-doc -->
097             * @see #getDetails()
098             * @generated
099             * @ordered
100             */
101            protected String details = DETAILS_EDEFAULT;
102    
103            /**
104             * The default value of the '{@link #getIndex() <em>Index</em>}' attribute.
105             * <!-- begin-user-doc -->
106             * <!-- end-user-doc -->
107             * @see #getIndex()
108             * @generated
109             * @ordered
110             */
111            protected static final int INDEX_EDEFAULT = 0;
112    
113            /**
114             * The cached value of the '{@link #getIndex() <em>Index</em>}' attribute.
115             * <!-- begin-user-doc -->
116             * <!-- end-user-doc -->
117             * @see #getIndex()
118             * @generated
119             * @ordered
120             */
121            protected int index = INDEX_EDEFAULT;
122    
123            /**
124             * The cached value of the '{@link #getJoinNode() <em>Join Node</em>}' reference.
125             * <!-- begin-user-doc -->
126             * <!-- end-user-doc -->
127             * @see #getJoinNode()
128             * @generated
129             * @ordered
130             */
131            protected JoinNode joinNode;
132    
133            /**
134             * <!-- begin-user-doc -->
135             * <!-- end-user-doc -->
136             * @generated
137             */
138            protected JoinInputImpl() {
139                    super();
140            }
141    
142            /**
143             * <!-- begin-user-doc -->
144             * <!-- end-user-doc -->
145             * @generated
146             */
147            @Override
148            protected EClass eStaticClass() {
149                    return SnapshotPackage.Literals.JOIN_INPUT;
150            }
151    
152            /**
153             * <!-- begin-user-doc -->
154             * <!-- end-user-doc -->
155             * @generated
156             */
157            public String getId() {
158                    return id;
159            }
160    
161            /**
162             * <!-- begin-user-doc -->
163             * <!-- end-user-doc -->
164             * @generated
165             */
166            public void setId(String newId) {
167                    String oldId = id;
168                    id = newId;
169                    if (eNotificationRequired())
170                            eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.JOIN_INPUT__ID, oldId, id));
171            }
172    
173            /**
174             * <!-- begin-user-doc -->
175             * <!-- end-user-doc -->
176             * @generated
177             */
178            public String getName() {
179                    return name;
180            }
181    
182            /**
183             * <!-- begin-user-doc -->
184             * <!-- end-user-doc -->
185             * @generated
186             */
187            public void setName(String newName) {
188                    String oldName = name;
189                    name = newName;
190                    if (eNotificationRequired())
191                            eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.JOIN_INPUT__NAME, oldName, name));
192            }
193    
194            /**
195             * <!-- begin-user-doc -->
196             * <!-- end-user-doc -->
197             * @generated
198             */
199            public String getDetails() {
200                    return details;
201            }
202    
203            /**
204             * <!-- begin-user-doc -->
205             * <!-- end-user-doc -->
206             * @generated
207             */
208            public void setDetails(String newDetails) {
209                    String oldDetails = details;
210                    details = newDetails;
211                    if (eNotificationRequired())
212                            eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.JOIN_INPUT__DETAILS, oldDetails, details));
213            }
214    
215            /**
216             * <!-- begin-user-doc -->
217             * <!-- end-user-doc -->
218             * @generated
219             */
220            public Snapshot getSnapshot() {
221                    if (eContainerFeatureID() != SnapshotPackage.JOIN_INPUT__SNAPSHOT) return null;
222                    return (Snapshot)eContainer();
223            }
224    
225            /**
226             * <!-- begin-user-doc -->
227             * <!-- end-user-doc -->
228             * @generated
229             */
230            public NotificationChain basicSetSnapshot(Snapshot newSnapshot, NotificationChain msgs) {
231                    msgs = eBasicSetContainer((InternalEObject)newSnapshot, SnapshotPackage.JOIN_INPUT__SNAPSHOT, msgs);
232                    return msgs;
233            }
234    
235            /**
236             * <!-- begin-user-doc -->
237             * <!-- end-user-doc -->
238             * @generated
239             */
240            public void setSnapshot(Snapshot newSnapshot) {
241                    if (newSnapshot != eInternalContainer() || (eContainerFeatureID() != SnapshotPackage.JOIN_INPUT__SNAPSHOT && newSnapshot != null)) {
242                            if (EcoreUtil.isAncestor(this, newSnapshot))
243                                    throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
244                            NotificationChain msgs = null;
245                            if (eInternalContainer() != null)
246                                    msgs = eBasicRemoveFromContainer(msgs);
247                            if (newSnapshot != null)
248                                    msgs = ((InternalEObject)newSnapshot).eInverseAdd(this, SnapshotPackage.SNAPSHOT__ELEMENTS, Snapshot.class, msgs);
249                            msgs = basicSetSnapshot(newSnapshot, msgs);
250                            if (msgs != null) msgs.dispatch();
251                    }
252                    else if (eNotificationRequired())
253                            eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.JOIN_INPUT__SNAPSHOT, newSnapshot, newSnapshot));
254            }
255    
256            /**
257             * <!-- begin-user-doc -->
258             * <!-- end-user-doc -->
259             * @generated
260             */
261            public int getIndex() {
262                    return index;
263            }
264    
265            /**
266             * <!-- begin-user-doc -->
267             * <!-- end-user-doc -->
268             * @generated
269             */
270            public void setIndex(int newIndex) {
271                    int oldIndex = index;
272                    index = newIndex;
273                    if (eNotificationRequired())
274                            eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.JOIN_INPUT__INDEX, oldIndex, index));
275            }
276    
277            /**
278             * <!-- begin-user-doc -->
279             * <!-- end-user-doc -->
280             * @generated
281             */
282            public JoinNode getJoinNode() {
283                    if (joinNode != null && joinNode.eIsProxy()) {
284                            InternalEObject oldJoinNode = (InternalEObject)joinNode;
285                            joinNode = (JoinNode)eResolveProxy(oldJoinNode);
286                            if (joinNode != oldJoinNode) {
287                                    if (eNotificationRequired())
288                                            eNotify(new ENotificationImpl(this, Notification.RESOLVE, SnapshotPackage.JOIN_INPUT__JOIN_NODE, oldJoinNode, joinNode));
289                            }
290                    }
291                    return joinNode;
292            }
293    
294            /**
295             * <!-- begin-user-doc -->
296             * <!-- end-user-doc -->
297             * @generated
298             */
299            public JoinNode basicGetJoinNode() {
300                    return joinNode;
301            }
302    
303            /**
304             * <!-- begin-user-doc -->
305             * <!-- end-user-doc -->
306             * @generated
307             */
308            public NotificationChain basicSetJoinNode(JoinNode newJoinNode, NotificationChain msgs) {
309                    JoinNode oldJoinNode = joinNode;
310                    joinNode = newJoinNode;
311                    if (eNotificationRequired()) {
312                            ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SnapshotPackage.JOIN_INPUT__JOIN_NODE, oldJoinNode, newJoinNode);
313                            if (msgs == null) msgs = notification; else msgs.add(notification);
314                    }
315                    return msgs;
316            }
317    
318            /**
319             * <!-- begin-user-doc -->
320             * <!-- end-user-doc -->
321             * @generated
322             */
323            public void setJoinNode(JoinNode newJoinNode) {
324                    if (newJoinNode != joinNode) {
325                            NotificationChain msgs = null;
326                            if (joinNode != null)
327                                    msgs = ((InternalEObject)joinNode).eInverseRemove(this, SnapshotPackage.JOIN_NODE__JOIN_INPUTS, JoinNode.class, msgs);
328                            if (newJoinNode != null)
329                                    msgs = ((InternalEObject)newJoinNode).eInverseAdd(this, SnapshotPackage.JOIN_NODE__JOIN_INPUTS, JoinNode.class, msgs);
330                            msgs = basicSetJoinNode(newJoinNode, msgs);
331                            if (msgs != null) msgs.dispatch();
332                    }
333                    else if (eNotificationRequired())
334                            eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.JOIN_INPUT__JOIN_NODE, newJoinNode, newJoinNode));
335            }
336    
337            /**
338             * <!-- begin-user-doc -->
339             * <!-- end-user-doc -->
340             * @generated
341             */
342            @Override
343            public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
344                    switch (featureID) {
345                            case SnapshotPackage.JOIN_INPUT__SNAPSHOT:
346                                    if (eInternalContainer() != null)
347                                            msgs = eBasicRemoveFromContainer(msgs);
348                                    return basicSetSnapshot((Snapshot)otherEnd, msgs);
349                            case SnapshotPackage.JOIN_INPUT__JOIN_NODE:
350                                    if (joinNode != null)
351                                            msgs = ((InternalEObject)joinNode).eInverseRemove(this, SnapshotPackage.JOIN_NODE__JOIN_INPUTS, JoinNode.class, msgs);
352                                    return basicSetJoinNode((JoinNode)otherEnd, msgs);
353                    }
354                    return super.eInverseAdd(otherEnd, featureID, msgs);
355            }
356    
357            /**
358             * <!-- begin-user-doc -->
359             * <!-- end-user-doc -->
360             * @generated
361             */
362            @Override
363            public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
364                    switch (featureID) {
365                            case SnapshotPackage.JOIN_INPUT__SNAPSHOT:
366                                    return basicSetSnapshot(null, msgs);
367                            case SnapshotPackage.JOIN_INPUT__JOIN_NODE:
368                                    return basicSetJoinNode(null, msgs);
369                    }
370                    return super.eInverseRemove(otherEnd, featureID, msgs);
371            }
372    
373            /**
374             * <!-- begin-user-doc -->
375             * <!-- end-user-doc -->
376             * @generated
377             */
378            @Override
379            public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
380                    switch (eContainerFeatureID()) {
381                            case SnapshotPackage.JOIN_INPUT__SNAPSHOT:
382                                    return eInternalContainer().eInverseRemove(this, SnapshotPackage.SNAPSHOT__ELEMENTS, Snapshot.class, msgs);
383                    }
384                    return super.eBasicRemoveFromContainerFeature(msgs);
385            }
386    
387            /**
388             * <!-- begin-user-doc -->
389             * <!-- end-user-doc -->
390             * @generated
391             */
392            @Override
393            public Object eGet(int featureID, boolean resolve, boolean coreType) {
394                    switch (featureID) {
395                            case SnapshotPackage.JOIN_INPUT__ID:
396                                    return getId();
397                            case SnapshotPackage.JOIN_INPUT__NAME:
398                                    return getName();
399                            case SnapshotPackage.JOIN_INPUT__DETAILS:
400                                    return getDetails();
401                            case SnapshotPackage.JOIN_INPUT__SNAPSHOT:
402                                    return getSnapshot();
403                            case SnapshotPackage.JOIN_INPUT__INDEX:
404                                    return getIndex();
405                            case SnapshotPackage.JOIN_INPUT__JOIN_NODE:
406                                    if (resolve) return getJoinNode();
407                                    return basicGetJoinNode();
408                    }
409                    return super.eGet(featureID, resolve, coreType);
410            }
411    
412            /**
413             * <!-- begin-user-doc -->
414             * <!-- end-user-doc -->
415             * @generated
416             */
417            @Override
418            public void eSet(int featureID, Object newValue) {
419                    switch (featureID) {
420                            case SnapshotPackage.JOIN_INPUT__ID:
421                                    setId((String)newValue);
422                                    return;
423                            case SnapshotPackage.JOIN_INPUT__NAME:
424                                    setName((String)newValue);
425                                    return;
426                            case SnapshotPackage.JOIN_INPUT__DETAILS:
427                                    setDetails((String)newValue);
428                                    return;
429                            case SnapshotPackage.JOIN_INPUT__SNAPSHOT:
430                                    setSnapshot((Snapshot)newValue);
431                                    return;
432                            case SnapshotPackage.JOIN_INPUT__INDEX:
433                                    setIndex((Integer)newValue);
434                                    return;
435                            case SnapshotPackage.JOIN_INPUT__JOIN_NODE:
436                                    setJoinNode((JoinNode)newValue);
437                                    return;
438                    }
439                    super.eSet(featureID, newValue);
440            }
441    
442            /**
443             * <!-- begin-user-doc -->
444             * <!-- end-user-doc -->
445             * @generated
446             */
447            @Override
448            public void eUnset(int featureID) {
449                    switch (featureID) {
450                            case SnapshotPackage.JOIN_INPUT__ID:
451                                    setId(ID_EDEFAULT);
452                                    return;
453                            case SnapshotPackage.JOIN_INPUT__NAME:
454                                    setName(NAME_EDEFAULT);
455                                    return;
456                            case SnapshotPackage.JOIN_INPUT__DETAILS:
457                                    setDetails(DETAILS_EDEFAULT);
458                                    return;
459                            case SnapshotPackage.JOIN_INPUT__SNAPSHOT:
460                                    setSnapshot((Snapshot)null);
461                                    return;
462                            case SnapshotPackage.JOIN_INPUT__INDEX:
463                                    setIndex(INDEX_EDEFAULT);
464                                    return;
465                            case SnapshotPackage.JOIN_INPUT__JOIN_NODE:
466                                    setJoinNode((JoinNode)null);
467                                    return;
468                    }
469                    super.eUnset(featureID);
470            }
471    
472            /**
473             * <!-- begin-user-doc -->
474             * <!-- end-user-doc -->
475             * @generated
476             */
477            @Override
478            public boolean eIsSet(int featureID) {
479                    switch (featureID) {
480                            case SnapshotPackage.JOIN_INPUT__ID:
481                                    return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
482                            case SnapshotPackage.JOIN_INPUT__NAME:
483                                    return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
484                            case SnapshotPackage.JOIN_INPUT__DETAILS:
485                                    return DETAILS_EDEFAULT == null ? details != null : !DETAILS_EDEFAULT.equals(details);
486                            case SnapshotPackage.JOIN_INPUT__SNAPSHOT:
487                                    return getSnapshot() != null;
488                            case SnapshotPackage.JOIN_INPUT__INDEX:
489                                    return index != INDEX_EDEFAULT;
490                            case SnapshotPackage.JOIN_INPUT__JOIN_NODE:
491                                    return joinNode != null;
492                    }
493                    return super.eIsSet(featureID);
494            }
495    
496            /**
497             * <!-- begin-user-doc -->
498             * <!-- end-user-doc -->
499             * @generated
500             */
501            @Override
502            public String toString() {
503                    if (eIsProxy()) return super.toString();
504    
505                    StringBuffer result = new StringBuffer(super.toString());
506                    result.append(" (id: ");
507                    result.append(id);
508                    result.append(", name: ");
509                    result.append(name);
510                    result.append(", details: ");
511                    result.append(details);
512                    result.append(", index: ");
513                    result.append(index);
514                    result.append(')');
515                    return result.toString();
516            }
517    
518    } //JoinInputImpl