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