001    /**
002     * <copyright>
003     * </copyright>
004     *
005     * $Id$
006     */
007    package com.hammurapi.eventbus.snapshot.impl;
008    
009    import com.hammurapi.eventbus.snapshot.Snapshot;
010    import com.hammurapi.eventbus.snapshot.SnapshotElement;
011    import com.hammurapi.eventbus.snapshot.SnapshotPackage;
012    
013    import java.util.Collection;
014    import java.util.Date;
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.EObjectContainmentWithInverseEList;
028    import org.eclipse.emf.ecore.util.EObjectContainmentEList;
029    import org.eclipse.emf.ecore.util.InternalEList;
030    
031    /**
032     * <!-- begin-user-doc -->
033     * An implementation of the model object '<em><b>Snapshot</b></em>'.
034     * <!-- end-user-doc -->
035     * <p>
036     * The following features are implemented:
037     * <ul>
038     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.SnapshotImpl#getTimestamp <em>Timestamp</em>}</li>
039     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.SnapshotImpl#getElements <em>Elements</em>}</li>
040     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.SnapshotImpl#getJvmId <em>Jvm Id</em>}</li>
041     * </ul>
042     * </p>
043     *
044     * @generated
045     */
046    public class SnapshotImpl extends EObjectImpl implements Snapshot {
047            /**
048             * The default value of the '{@link #getTimestamp() <em>Timestamp</em>}' attribute.
049             * <!-- begin-user-doc -->
050             * <!-- end-user-doc -->
051             * @see #getTimestamp()
052             * @generated
053             * @ordered
054             */
055            protected static final Date TIMESTAMP_EDEFAULT = null;
056    
057            /**
058             * The cached value of the '{@link #getTimestamp() <em>Timestamp</em>}' attribute.
059             * <!-- begin-user-doc -->
060             * <!-- end-user-doc -->
061             * @see #getTimestamp()
062             * @generated
063             * @ordered
064             */
065            protected Date timestamp = TIMESTAMP_EDEFAULT;
066    
067            /**
068             * The cached value of the '{@link #getElements() <em>Elements</em>}' containment reference list.
069             * <!-- begin-user-doc -->
070             * <!-- end-user-doc -->
071             * @see #getElements()
072             * @generated
073             * @ordered
074             */
075            protected EList<SnapshotElement> elements;
076    
077            /**
078             * The default value of the '{@link #getJvmId() <em>Jvm Id</em>}' attribute.
079             * <!-- begin-user-doc -->
080             * <!-- end-user-doc -->
081             * @see #getJvmId()
082             * @generated
083             * @ordered
084             */
085            protected static final String JVM_ID_EDEFAULT = null;
086    
087            /**
088             * The cached value of the '{@link #getJvmId() <em>Jvm Id</em>}' attribute.
089             * <!-- begin-user-doc -->
090             * <!-- end-user-doc -->
091             * @see #getJvmId()
092             * @generated
093             * @ordered
094             */
095            protected String jvmId = JVM_ID_EDEFAULT;
096    
097            /**
098             * <!-- begin-user-doc -->
099             * <!-- end-user-doc -->
100             * @generated
101             */
102            protected SnapshotImpl() {
103                    super();
104            }
105    
106            /**
107             * <!-- begin-user-doc -->
108             * <!-- end-user-doc -->
109             * @generated
110             */
111            @Override
112            protected EClass eStaticClass() {
113                    return SnapshotPackage.Literals.SNAPSHOT;
114            }
115    
116            /**
117             * <!-- begin-user-doc -->
118             * <!-- end-user-doc -->
119             * @generated
120             */
121            public Date getTimestamp() {
122                    return timestamp;
123            }
124    
125            /**
126             * <!-- begin-user-doc -->
127             * <!-- end-user-doc -->
128             * @generated
129             */
130            public void setTimestamp(Date newTimestamp) {
131                    Date oldTimestamp = timestamp;
132                    timestamp = newTimestamp;
133                    if (eNotificationRequired())
134                            eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.SNAPSHOT__TIMESTAMP, oldTimestamp, timestamp));
135            }
136    
137            /**
138             * <!-- begin-user-doc -->
139             * <!-- end-user-doc -->
140             * @generated
141             */
142            public EList<SnapshotElement> getElements() {
143                    if (elements == null) {
144                            elements = new EObjectContainmentWithInverseEList<SnapshotElement>(SnapshotElement.class, this, SnapshotPackage.SNAPSHOT__ELEMENTS, SnapshotPackage.SNAPSHOT_ELEMENT__SNAPSHOT);
145                    }
146                    return elements;
147            }
148    
149            /**
150             * <!-- begin-user-doc -->
151             * <!-- end-user-doc -->
152             * @generated
153             */
154            public String getJvmId() {
155                    return jvmId;
156            }
157    
158            /**
159             * <!-- begin-user-doc -->
160             * <!-- end-user-doc -->
161             * @generated
162             */
163            public void setJvmId(String newJvmId) {
164                    String oldJvmId = jvmId;
165                    jvmId = newJvmId;
166                    if (eNotificationRequired())
167                            eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.SNAPSHOT__JVM_ID, oldJvmId, jvmId));
168            }
169    
170            /**
171             * <!-- begin-user-doc -->
172             * <!-- end-user-doc -->
173             * @generated
174             */
175            @SuppressWarnings("unchecked")
176            @Override
177            public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
178                    switch (featureID) {
179                            case SnapshotPackage.SNAPSHOT__ELEMENTS:
180                                    return ((InternalEList<InternalEObject>)(InternalEList<?>)getElements()).basicAdd(otherEnd, msgs);
181                    }
182                    return super.eInverseAdd(otherEnd, featureID, msgs);
183            }
184    
185            /**
186             * <!-- begin-user-doc -->
187             * <!-- end-user-doc -->
188             * @generated
189             */
190            @Override
191            public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
192                    switch (featureID) {
193                            case SnapshotPackage.SNAPSHOT__ELEMENTS:
194                                    return ((InternalEList<?>)getElements()).basicRemove(otherEnd, msgs);
195                    }
196                    return super.eInverseRemove(otherEnd, featureID, msgs);
197            }
198    
199            /**
200             * <!-- begin-user-doc -->
201             * <!-- end-user-doc -->
202             * @generated
203             */
204            @Override
205            public Object eGet(int featureID, boolean resolve, boolean coreType) {
206                    switch (featureID) {
207                            case SnapshotPackage.SNAPSHOT__TIMESTAMP:
208                                    return getTimestamp();
209                            case SnapshotPackage.SNAPSHOT__ELEMENTS:
210                                    return getElements();
211                            case SnapshotPackage.SNAPSHOT__JVM_ID:
212                                    return getJvmId();
213                    }
214                    return super.eGet(featureID, resolve, coreType);
215            }
216    
217            /**
218             * <!-- begin-user-doc -->
219             * <!-- end-user-doc -->
220             * @generated
221             */
222            @SuppressWarnings("unchecked")
223            @Override
224            public void eSet(int featureID, Object newValue) {
225                    switch (featureID) {
226                            case SnapshotPackage.SNAPSHOT__TIMESTAMP:
227                                    setTimestamp((Date)newValue);
228                                    return;
229                            case SnapshotPackage.SNAPSHOT__ELEMENTS:
230                                    getElements().clear();
231                                    getElements().addAll((Collection<? extends SnapshotElement>)newValue);
232                                    return;
233                            case SnapshotPackage.SNAPSHOT__JVM_ID:
234                                    setJvmId((String)newValue);
235                                    return;
236                    }
237                    super.eSet(featureID, newValue);
238            }
239    
240            /**
241             * <!-- begin-user-doc -->
242             * <!-- end-user-doc -->
243             * @generated
244             */
245            @Override
246            public void eUnset(int featureID) {
247                    switch (featureID) {
248                            case SnapshotPackage.SNAPSHOT__TIMESTAMP:
249                                    setTimestamp(TIMESTAMP_EDEFAULT);
250                                    return;
251                            case SnapshotPackage.SNAPSHOT__ELEMENTS:
252                                    getElements().clear();
253                                    return;
254                            case SnapshotPackage.SNAPSHOT__JVM_ID:
255                                    setJvmId(JVM_ID_EDEFAULT);
256                                    return;
257                    }
258                    super.eUnset(featureID);
259            }
260    
261            /**
262             * <!-- begin-user-doc -->
263             * <!-- end-user-doc -->
264             * @generated
265             */
266            @Override
267            public boolean eIsSet(int featureID) {
268                    switch (featureID) {
269                            case SnapshotPackage.SNAPSHOT__TIMESTAMP:
270                                    return TIMESTAMP_EDEFAULT == null ? timestamp != null : !TIMESTAMP_EDEFAULT.equals(timestamp);
271                            case SnapshotPackage.SNAPSHOT__ELEMENTS:
272                                    return elements != null && !elements.isEmpty();
273                            case SnapshotPackage.SNAPSHOT__JVM_ID:
274                                    return JVM_ID_EDEFAULT == null ? jvmId != null : !JVM_ID_EDEFAULT.equals(jvmId);
275                    }
276                    return super.eIsSet(featureID);
277            }
278    
279            /**
280             * <!-- begin-user-doc -->
281             * <!-- end-user-doc -->
282             * @generated
283             */
284            @Override
285            public String toString() {
286                    if (eIsProxy()) return super.toString();
287    
288                    StringBuffer result = new StringBuffer(super.toString());
289                    result.append(" (timestamp: ");
290                    result.append(timestamp);
291                    result.append(", jvmId: ");
292                    result.append(jvmId);
293                    result.append(')');
294                    return result.toString();
295            }
296    
297    } //SnapshotImpl