1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package com.hammurapi.eventbus.snapshot.impl; |
8 | |
9 | import com.hammurapi.eventbus.snapshot.Snapshot; |
10 | import com.hammurapi.eventbus.snapshot.SnapshotElement; |
11 | import com.hammurapi.eventbus.snapshot.SnapshotPackage; |
12 | |
13 | import java.util.Collection; |
14 | import java.util.Date; |
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.EObjectContainmentWithInverseEList; |
28 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
29 | import org.eclipse.emf.ecore.util.InternalEList; |
30 | |
31 | /** |
32 | * <!-- begin-user-doc --> |
33 | * An implementation of the model object '<em><b>Snapshot</b></em>'. |
34 | * <!-- end-user-doc --> |
35 | * <p> |
36 | * The following features are implemented: |
37 | * <ul> |
38 | * <li>{@link com.hammurapi.eventbus.snapshot.impl.SnapshotImpl#getTimestamp <em>Timestamp</em>}</li> |
39 | * <li>{@link com.hammurapi.eventbus.snapshot.impl.SnapshotImpl#getElements <em>Elements</em>}</li> |
40 | * <li>{@link com.hammurapi.eventbus.snapshot.impl.SnapshotImpl#getJvmId <em>Jvm Id</em>}</li> |
41 | * </ul> |
42 | * </p> |
43 | * |
44 | * @generated |
45 | */ |
46 | public class SnapshotImpl extends EObjectImpl implements Snapshot { |
47 | /** |
48 | * The default value of the '{@link #getTimestamp() <em>Timestamp</em>}' attribute. |
49 | * <!-- begin-user-doc --> |
50 | * <!-- end-user-doc --> |
51 | * @see #getTimestamp() |
52 | * @generated |
53 | * @ordered |
54 | */ |
55 | protected static final Date TIMESTAMP_EDEFAULT = null; |
56 | |
57 | /** |
58 | * The cached value of the '{@link #getTimestamp() <em>Timestamp</em>}' attribute. |
59 | * <!-- begin-user-doc --> |
60 | * <!-- end-user-doc --> |
61 | * @see #getTimestamp() |
62 | * @generated |
63 | * @ordered |
64 | */ |
65 | protected Date timestamp = TIMESTAMP_EDEFAULT; |
66 | |
67 | /** |
68 | * The cached value of the '{@link #getElements() <em>Elements</em>}' containment reference list. |
69 | * <!-- begin-user-doc --> |
70 | * <!-- end-user-doc --> |
71 | * @see #getElements() |
72 | * @generated |
73 | * @ordered |
74 | */ |
75 | protected EList<SnapshotElement> elements; |
76 | |
77 | /** |
78 | * The default value of the '{@link #getJvmId() <em>Jvm Id</em>}' attribute. |
79 | * <!-- begin-user-doc --> |
80 | * <!-- end-user-doc --> |
81 | * @see #getJvmId() |
82 | * @generated |
83 | * @ordered |
84 | */ |
85 | protected static final String JVM_ID_EDEFAULT = null; |
86 | |
87 | /** |
88 | * The cached value of the '{@link #getJvmId() <em>Jvm Id</em>}' attribute. |
89 | * <!-- begin-user-doc --> |
90 | * <!-- end-user-doc --> |
91 | * @see #getJvmId() |
92 | * @generated |
93 | * @ordered |
94 | */ |
95 | protected String jvmId = JVM_ID_EDEFAULT; |
96 | |
97 | /** |
98 | * <!-- begin-user-doc --> |
99 | * <!-- 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 |