001 /**
002 * <copyright>
003 * </copyright>
004 *
005 * $Id$
006 */
007 package com.hammurapi.eventbus.snapshot.impl;
008
009 import com.hammurapi.eventbus.snapshot.Predicate;
010 import com.hammurapi.eventbus.snapshot.PredicateNode;
011 import com.hammurapi.eventbus.snapshot.PredicateNodeOutput;
012 import com.hammurapi.eventbus.snapshot.Snapshot;
013 import com.hammurapi.eventbus.snapshot.SnapshotPackage;
014
015 import java.util.Collection;
016
017 import org.eclipse.emf.common.notify.Notification;
018
019 import org.eclipse.emf.common.notify.NotificationChain;
020 import org.eclipse.emf.common.util.EList;
021
022 import org.eclipse.emf.ecore.EClass;
023
024 import org.eclipse.emf.ecore.InternalEObject;
025 import org.eclipse.emf.ecore.impl.ENotificationImpl;
026 import org.eclipse.emf.ecore.impl.EObjectImpl;
027
028 import org.eclipse.emf.ecore.util.EObjectResolvingEList;
029 import org.eclipse.emf.ecore.util.EcoreUtil;
030
031 /**
032 * <!-- begin-user-doc -->
033 * An implementation of the model object '<em><b>Predicate Node</b></em>'.
034 * <!-- end-user-doc -->
035 * <p>
036 * The following features are implemented:
037 * <ul>
038 * <li>{@link com.hammurapi.eventbus.snapshot.impl.PredicateNodeImpl#getId <em>Id</em>}</li>
039 * <li>{@link com.hammurapi.eventbus.snapshot.impl.PredicateNodeImpl#getName <em>Name</em>}</li>
040 * <li>{@link com.hammurapi.eventbus.snapshot.impl.PredicateNodeImpl#getDetails <em>Details</em>}</li>
041 * <li>{@link com.hammurapi.eventbus.snapshot.impl.PredicateNodeImpl#getSnapshot <em>Snapshot</em>}</li>
042 * <li>{@link com.hammurapi.eventbus.snapshot.impl.PredicateNodeImpl#getTrueOutputs <em>True Outputs</em>}</li>
043 * <li>{@link com.hammurapi.eventbus.snapshot.impl.PredicateNodeImpl#getFalseOutputs <em>False Outputs</em>}</li>
044 * <li>{@link com.hammurapi.eventbus.snapshot.impl.PredicateNodeImpl#getTrueChildren <em>True Children</em>}</li>
045 * <li>{@link com.hammurapi.eventbus.snapshot.impl.PredicateNodeImpl#getFalseChildren <em>False Children</em>}</li>
046 * <li>{@link com.hammurapi.eventbus.snapshot.impl.PredicateNodeImpl#isIsRoot <em>Is Root</em>}</li>
047 * <li>{@link com.hammurapi.eventbus.snapshot.impl.PredicateNodeImpl#getPredicate <em>Predicate</em>}</li>
048 * </ul>
049 * </p>
050 *
051 * @generated
052 */
053 public class PredicateNodeImpl extends EObjectImpl implements PredicateNode {
054 /**
055 * The default value of the '{@link #getId() <em>Id</em>}' attribute.
056 * <!-- begin-user-doc -->
057 * <!-- end-user-doc -->
058 * @see #getId()
059 * @generated
060 * @ordered
061 */
062 protected static final String ID_EDEFAULT = null;
063
064 /**
065 * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
066 * <!-- begin-user-doc -->
067 * <!-- end-user-doc -->
068 * @see #getId()
069 * @generated
070 * @ordered
071 */
072 protected String id = ID_EDEFAULT;
073
074 /**
075 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
076 * <!-- begin-user-doc -->
077 * <!-- end-user-doc -->
078 * @see #getName()
079 * @generated
080 * @ordered
081 */
082 protected static final String NAME_EDEFAULT = null;
083
084 /**
085 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
086 * <!-- begin-user-doc -->
087 * <!-- end-user-doc -->
088 * @see #getName()
089 * @generated
090 * @ordered
091 */
092 protected String name = NAME_EDEFAULT;
093
094 /**
095 * The default value of the '{@link #getDetails() <em>Details</em>}' attribute.
096 * <!-- begin-user-doc -->
097 * <!-- end-user-doc -->
098 * @see #getDetails()
099 * @generated
100 * @ordered
101 */
102 protected static final String DETAILS_EDEFAULT = null;
103
104 /**
105 * The cached value of the '{@link #getDetails() <em>Details</em>}' attribute.
106 * <!-- begin-user-doc -->
107 * <!-- end-user-doc -->
108 * @see #getDetails()
109 * @generated
110 * @ordered
111 */
112 protected String details = DETAILS_EDEFAULT;
113
114 /**
115 * The cached value of the '{@link #getTrueOutputs() <em>True Outputs</em>}' reference list.
116 * <!-- begin-user-doc -->
117 * <!-- end-user-doc -->
118 * @see #getTrueOutputs()
119 * @generated
120 * @ordered
121 */
122 protected EList<PredicateNodeOutput> trueOutputs;
123
124 /**
125 * The cached value of the '{@link #getFalseOutputs() <em>False Outputs</em>}' reference list.
126 * <!-- begin-user-doc -->
127 * <!-- end-user-doc -->
128 * @see #getFalseOutputs()
129 * @generated
130 * @ordered
131 */
132 protected EList<PredicateNodeOutput> falseOutputs;
133
134 /**
135 * The cached value of the '{@link #getTrueChildren() <em>True Children</em>}' reference list.
136 * <!-- begin-user-doc -->
137 * <!-- end-user-doc -->
138 * @see #getTrueChildren()
139 * @generated
140 * @ordered
141 */
142 protected EList<PredicateNode> trueChildren;
143
144 /**
145 * The cached value of the '{@link #getFalseChildren() <em>False Children</em>}' reference list.
146 * <!-- begin-user-doc -->
147 * <!-- end-user-doc -->
148 * @see #getFalseChildren()
149 * @generated
150 * @ordered
151 */
152 protected EList<PredicateNode> falseChildren;
153
154 /**
155 * The default value of the '{@link #isIsRoot() <em>Is Root</em>}' attribute.
156 * <!-- begin-user-doc -->
157 * <!-- end-user-doc -->
158 * @see #isIsRoot()
159 * @generated
160 * @ordered
161 */
162 protected static final boolean IS_ROOT_EDEFAULT = false;
163
164 /**
165 * The cached value of the '{@link #isIsRoot() <em>Is Root</em>}' attribute.
166 * <!-- begin-user-doc -->
167 * <!-- end-user-doc -->
168 * @see #isIsRoot()
169 * @generated
170 * @ordered
171 */
172 protected boolean isRoot = IS_ROOT_EDEFAULT;
173
174 /**
175 * The cached value of the '{@link #getPredicate() <em>Predicate</em>}' containment reference.
176 * <!-- begin-user-doc -->
177 * <!-- end-user-doc -->
178 * @see #getPredicate()
179 * @generated
180 * @ordered
181 */
182 protected Predicate predicate;
183
184 /**
185 * <!-- begin-user-doc -->
186 * <!-- end-user-doc -->
187 * @generated
188 */
189 protected PredicateNodeImpl() {
190 super();
191 }
192
193 /**
194 * <!-- begin-user-doc -->
195 * <!-- end-user-doc -->
196 * @generated
197 */
198 @Override
199 protected EClass eStaticClass() {
200 return SnapshotPackage.Literals.PREDICATE_NODE;
201 }
202
203 /**
204 * <!-- begin-user-doc -->
205 * <!-- end-user-doc -->
206 * @generated
207 */
208 public String getId() {
209 return id;
210 }
211
212 /**
213 * <!-- begin-user-doc -->
214 * <!-- end-user-doc -->
215 * @generated
216 */
217 public void setId(String newId) {
218 String oldId = id;
219 id = newId;
220 if (eNotificationRequired())
221 eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.PREDICATE_NODE__ID, oldId, id));
222 }
223
224 /**
225 * <!-- begin-user-doc -->
226 * <!-- end-user-doc -->
227 * @generated
228 */
229 public String getName() {
230 return name;
231 }
232
233 /**
234 * <!-- begin-user-doc -->
235 * <!-- end-user-doc -->
236 * @generated
237 */
238 public void setName(String newName) {
239 String oldName = name;
240 name = newName;
241 if (eNotificationRequired())
242 eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.PREDICATE_NODE__NAME, oldName, name));
243 }
244
245 /**
246 * <!-- begin-user-doc -->
247 * <!-- end-user-doc -->
248 * @generated
249 */
250 public String getDetails() {
251 return details;
252 }
253
254 /**
255 * <!-- begin-user-doc -->
256 * <!-- end-user-doc -->
257 * @generated
258 */
259 public void setDetails(String newDetails) {
260 String oldDetails = details;
261 details = newDetails;
262 if (eNotificationRequired())
263 eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.PREDICATE_NODE__DETAILS, oldDetails, details));
264 }
265
266 /**
267 * <!-- begin-user-doc -->
268 * <!-- end-user-doc -->
269 * @generated
270 */
271 public Snapshot getSnapshot() {
272 if (eContainerFeatureID() != SnapshotPackage.PREDICATE_NODE__SNAPSHOT) return null;
273 return (Snapshot)eContainer();
274 }
275
276 /**
277 * <!-- begin-user-doc -->
278 * <!-- end-user-doc -->
279 * @generated
280 */
281 public NotificationChain basicSetSnapshot(Snapshot newSnapshot, NotificationChain msgs) {
282 msgs = eBasicSetContainer((InternalEObject)newSnapshot, SnapshotPackage.PREDICATE_NODE__SNAPSHOT, msgs);
283 return msgs;
284 }
285
286 /**
287 * <!-- begin-user-doc -->
288 * <!-- end-user-doc -->
289 * @generated
290 */
291 public void setSnapshot(Snapshot newSnapshot) {
292 if (newSnapshot != eInternalContainer() || (eContainerFeatureID() != SnapshotPackage.PREDICATE_NODE__SNAPSHOT && newSnapshot != null)) {
293 if (EcoreUtil.isAncestor(this, newSnapshot))
294 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
295 NotificationChain msgs = null;
296 if (eInternalContainer() != null)
297 msgs = eBasicRemoveFromContainer(msgs);
298 if (newSnapshot != null)
299 msgs = ((InternalEObject)newSnapshot).eInverseAdd(this, SnapshotPackage.SNAPSHOT__ELEMENTS, Snapshot.class, msgs);
300 msgs = basicSetSnapshot(newSnapshot, msgs);
301 if (msgs != null) msgs.dispatch();
302 }
303 else if (eNotificationRequired())
304 eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.PREDICATE_NODE__SNAPSHOT, newSnapshot, newSnapshot));
305 }
306
307 /**
308 * <!-- begin-user-doc -->
309 * <!-- end-user-doc -->
310 * @generated
311 */
312 public EList<PredicateNodeOutput> getTrueOutputs() {
313 if (trueOutputs == null) {
314 trueOutputs = new EObjectResolvingEList<PredicateNodeOutput>(PredicateNodeOutput.class, this, SnapshotPackage.PREDICATE_NODE__TRUE_OUTPUTS);
315 }
316 return trueOutputs;
317 }
318
319 /**
320 * <!-- begin-user-doc -->
321 * <!-- end-user-doc -->
322 * @generated
323 */
324 public EList<PredicateNodeOutput> getFalseOutputs() {
325 if (falseOutputs == null) {
326 falseOutputs = new EObjectResolvingEList<PredicateNodeOutput>(PredicateNodeOutput.class, this, SnapshotPackage.PREDICATE_NODE__FALSE_OUTPUTS);
327 }
328 return falseOutputs;
329 }
330
331 /**
332 * <!-- begin-user-doc -->
333 * <!-- end-user-doc -->
334 * @generated
335 */
336 public EList<PredicateNode> getTrueChildren() {
337 if (trueChildren == null) {
338 trueChildren = new EObjectResolvingEList<PredicateNode>(PredicateNode.class, this, SnapshotPackage.PREDICATE_NODE__TRUE_CHILDREN);
339 }
340 return trueChildren;
341 }
342
343 /**
344 * <!-- begin-user-doc -->
345 * <!-- end-user-doc -->
346 * @generated
347 */
348 public EList<PredicateNode> getFalseChildren() {
349 if (falseChildren == null) {
350 falseChildren = new EObjectResolvingEList<PredicateNode>(PredicateNode.class, this, SnapshotPackage.PREDICATE_NODE__FALSE_CHILDREN);
351 }
352 return falseChildren;
353 }
354
355 /**
356 * <!-- begin-user-doc -->
357 * <!-- end-user-doc -->
358 * @generated
359 */
360 public boolean isIsRoot() {
361 return isRoot;
362 }
363
364 /**
365 * <!-- begin-user-doc -->
366 * <!-- end-user-doc -->
367 * @generated
368 */
369 public void setIsRoot(boolean newIsRoot) {
370 boolean oldIsRoot = isRoot;
371 isRoot = newIsRoot;
372 if (eNotificationRequired())
373 eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.PREDICATE_NODE__IS_ROOT, oldIsRoot, isRoot));
374 }
375
376 /**
377 * <!-- begin-user-doc -->
378 * <!-- end-user-doc -->
379 * @generated
380 */
381 public Predicate getPredicate() {
382 return predicate;
383 }
384
385 /**
386 * <!-- begin-user-doc -->
387 * <!-- end-user-doc -->
388 * @generated
389 */
390 public NotificationChain basicSetPredicate(Predicate newPredicate, NotificationChain msgs) {
391 Predicate oldPredicate = predicate;
392 predicate = newPredicate;
393 if (eNotificationRequired()) {
394 ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SnapshotPackage.PREDICATE_NODE__PREDICATE, oldPredicate, newPredicate);
395 if (msgs == null) msgs = notification; else msgs.add(notification);
396 }
397 return msgs;
398 }
399
400 /**
401 * <!-- begin-user-doc -->
402 * <!-- end-user-doc -->
403 * @generated
404 */
405 public void setPredicate(Predicate newPredicate) {
406 if (newPredicate != predicate) {
407 NotificationChain msgs = null;
408 if (predicate != null)
409 msgs = ((InternalEObject)predicate).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SnapshotPackage.PREDICATE_NODE__PREDICATE, null, msgs);
410 if (newPredicate != null)
411 msgs = ((InternalEObject)newPredicate).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SnapshotPackage.PREDICATE_NODE__PREDICATE, null, msgs);
412 msgs = basicSetPredicate(newPredicate, msgs);
413 if (msgs != null) msgs.dispatch();
414 }
415 else if (eNotificationRequired())
416 eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.PREDICATE_NODE__PREDICATE, newPredicate, newPredicate));
417 }
418
419 /**
420 * <!-- begin-user-doc -->
421 * <!-- end-user-doc -->
422 * @generated
423 */
424 @Override
425 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
426 switch (featureID) {
427 case SnapshotPackage.PREDICATE_NODE__SNAPSHOT:
428 if (eInternalContainer() != null)
429 msgs = eBasicRemoveFromContainer(msgs);
430 return basicSetSnapshot((Snapshot)otherEnd, msgs);
431 }
432 return super.eInverseAdd(otherEnd, featureID, msgs);
433 }
434
435 /**
436 * <!-- begin-user-doc -->
437 * <!-- end-user-doc -->
438 * @generated
439 */
440 @Override
441 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
442 switch (featureID) {
443 case SnapshotPackage.PREDICATE_NODE__SNAPSHOT:
444 return basicSetSnapshot(null, msgs);
445 case SnapshotPackage.PREDICATE_NODE__PREDICATE:
446 return basicSetPredicate(null, msgs);
447 }
448 return super.eInverseRemove(otherEnd, featureID, msgs);
449 }
450
451 /**
452 * <!-- begin-user-doc -->
453 * <!-- end-user-doc -->
454 * @generated
455 */
456 @Override
457 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
458 switch (eContainerFeatureID()) {
459 case SnapshotPackage.PREDICATE_NODE__SNAPSHOT:
460 return eInternalContainer().eInverseRemove(this, SnapshotPackage.SNAPSHOT__ELEMENTS, Snapshot.class, msgs);
461 }
462 return super.eBasicRemoveFromContainerFeature(msgs);
463 }
464
465 /**
466 * <!-- begin-user-doc -->
467 * <!-- end-user-doc -->
468 * @generated
469 */
470 @Override
471 public Object eGet(int featureID, boolean resolve, boolean coreType) {
472 switch (featureID) {
473 case SnapshotPackage.PREDICATE_NODE__ID:
474 return getId();
475 case SnapshotPackage.PREDICATE_NODE__NAME:
476 return getName();
477 case SnapshotPackage.PREDICATE_NODE__DETAILS:
478 return getDetails();
479 case SnapshotPackage.PREDICATE_NODE__SNAPSHOT:
480 return getSnapshot();
481 case SnapshotPackage.PREDICATE_NODE__TRUE_OUTPUTS:
482 return getTrueOutputs();
483 case SnapshotPackage.PREDICATE_NODE__FALSE_OUTPUTS:
484 return getFalseOutputs();
485 case SnapshotPackage.PREDICATE_NODE__TRUE_CHILDREN:
486 return getTrueChildren();
487 case SnapshotPackage.PREDICATE_NODE__FALSE_CHILDREN:
488 return getFalseChildren();
489 case SnapshotPackage.PREDICATE_NODE__IS_ROOT:
490 return isIsRoot();
491 case SnapshotPackage.PREDICATE_NODE__PREDICATE:
492 return getPredicate();
493 }
494 return super.eGet(featureID, resolve, coreType);
495 }
496
497 /**
498 * <!-- begin-user-doc -->
499 * <!-- end-user-doc -->
500 * @generated
501 */
502 @SuppressWarnings("unchecked")
503 @Override
504 public void eSet(int featureID, Object newValue) {
505 switch (featureID) {
506 case SnapshotPackage.PREDICATE_NODE__ID:
507 setId((String)newValue);
508 return;
509 case SnapshotPackage.PREDICATE_NODE__NAME:
510 setName((String)newValue);
511 return;
512 case SnapshotPackage.PREDICATE_NODE__DETAILS:
513 setDetails((String)newValue);
514 return;
515 case SnapshotPackage.PREDICATE_NODE__SNAPSHOT:
516 setSnapshot((Snapshot)newValue);
517 return;
518 case SnapshotPackage.PREDICATE_NODE__TRUE_OUTPUTS:
519 getTrueOutputs().clear();
520 getTrueOutputs().addAll((Collection<? extends PredicateNodeOutput>)newValue);
521 return;
522 case SnapshotPackage.PREDICATE_NODE__FALSE_OUTPUTS:
523 getFalseOutputs().clear();
524 getFalseOutputs().addAll((Collection<? extends PredicateNodeOutput>)newValue);
525 return;
526 case SnapshotPackage.PREDICATE_NODE__TRUE_CHILDREN:
527 getTrueChildren().clear();
528 getTrueChildren().addAll((Collection<? extends PredicateNode>)newValue);
529 return;
530 case SnapshotPackage.PREDICATE_NODE__FALSE_CHILDREN:
531 getFalseChildren().clear();
532 getFalseChildren().addAll((Collection<? extends PredicateNode>)newValue);
533 return;
534 case SnapshotPackage.PREDICATE_NODE__IS_ROOT:
535 setIsRoot((Boolean)newValue);
536 return;
537 case SnapshotPackage.PREDICATE_NODE__PREDICATE:
538 setPredicate((Predicate)newValue);
539 return;
540 }
541 super.eSet(featureID, newValue);
542 }
543
544 /**
545 * <!-- begin-user-doc -->
546 * <!-- end-user-doc -->
547 * @generated
548 */
549 @Override
550 public void eUnset(int featureID) {
551 switch (featureID) {
552 case SnapshotPackage.PREDICATE_NODE__ID:
553 setId(ID_EDEFAULT);
554 return;
555 case SnapshotPackage.PREDICATE_NODE__NAME:
556 setName(NAME_EDEFAULT);
557 return;
558 case SnapshotPackage.PREDICATE_NODE__DETAILS:
559 setDetails(DETAILS_EDEFAULT);
560 return;
561 case SnapshotPackage.PREDICATE_NODE__SNAPSHOT:
562 setSnapshot((Snapshot)null);
563 return;
564 case SnapshotPackage.PREDICATE_NODE__TRUE_OUTPUTS:
565 getTrueOutputs().clear();
566 return;
567 case SnapshotPackage.PREDICATE_NODE__FALSE_OUTPUTS:
568 getFalseOutputs().clear();
569 return;
570 case SnapshotPackage.PREDICATE_NODE__TRUE_CHILDREN:
571 getTrueChildren().clear();
572 return;
573 case SnapshotPackage.PREDICATE_NODE__FALSE_CHILDREN:
574 getFalseChildren().clear();
575 return;
576 case SnapshotPackage.PREDICATE_NODE__IS_ROOT:
577 setIsRoot(IS_ROOT_EDEFAULT);
578 return;
579 case SnapshotPackage.PREDICATE_NODE__PREDICATE:
580 setPredicate((Predicate)null);
581 return;
582 }
583 super.eUnset(featureID);
584 }
585
586 /**
587 * <!-- begin-user-doc -->
588 * <!-- end-user-doc -->
589 * @generated
590 */
591 @Override
592 public boolean eIsSet(int featureID) {
593 switch (featureID) {
594 case SnapshotPackage.PREDICATE_NODE__ID:
595 return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
596 case SnapshotPackage.PREDICATE_NODE__NAME:
597 return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
598 case SnapshotPackage.PREDICATE_NODE__DETAILS:
599 return DETAILS_EDEFAULT == null ? details != null : !DETAILS_EDEFAULT.equals(details);
600 case SnapshotPackage.PREDICATE_NODE__SNAPSHOT:
601 return getSnapshot() != null;
602 case SnapshotPackage.PREDICATE_NODE__TRUE_OUTPUTS:
603 return trueOutputs != null && !trueOutputs.isEmpty();
604 case SnapshotPackage.PREDICATE_NODE__FALSE_OUTPUTS:
605 return falseOutputs != null && !falseOutputs.isEmpty();
606 case SnapshotPackage.PREDICATE_NODE__TRUE_CHILDREN:
607 return trueChildren != null && !trueChildren.isEmpty();
608 case SnapshotPackage.PREDICATE_NODE__FALSE_CHILDREN:
609 return falseChildren != null && !falseChildren.isEmpty();
610 case SnapshotPackage.PREDICATE_NODE__IS_ROOT:
611 return isRoot != IS_ROOT_EDEFAULT;
612 case SnapshotPackage.PREDICATE_NODE__PREDICATE:
613 return predicate != null;
614 }
615 return super.eIsSet(featureID);
616 }
617
618 /**
619 * <!-- begin-user-doc -->
620 * <!-- end-user-doc -->
621 * @generated
622 */
623 @Override
624 public String toString() {
625 if (eIsProxy()) return super.toString();
626
627 StringBuffer result = new StringBuffer(super.toString());
628 result.append(" (id: ");
629 result.append(id);
630 result.append(", name: ");
631 result.append(name);
632 result.append(", details: ");
633 result.append(details);
634 result.append(", isRoot: ");
635 result.append(isRoot);
636 result.append(')');
637 return result.toString();
638 }
639
640 } //PredicateNodeImpl