1 /** 2 * <copyright> 3 * </copyright> 4 * 5 * $Id$ 6 */ 7 package org.eclipse.e4.emf.xpath.test.model.xpathtest.impl; 8 9 import java.util.Collection; 10 11 import org.eclipse.e4.emf.xpath.test.model.xpathtest.MenuElement; 12 import org.eclipse.e4.emf.xpath.test.model.xpathtest.Node; 13 import org.eclipse.e4.emf.xpath.test.model.xpathtest.Root; 14 import org.eclipse.e4.emf.xpath.test.model.xpathtest.XpathtestPackage; 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.EObjectContainmentEList; 28 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; 29 import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; 30 import org.eclipse.emf.ecore.util.EcoreUtil; 31 import org.eclipse.emf.ecore.util.InternalEList; 32 33 /** 34 * <!-- begin-user-doc --> 35 * An implementation of the model object '<em><b>Node</b></em>'. 36 * <!-- end-user-doc --> 37 * <p> 38 * The following features are implemented: 39 * <ul> 40 * <li>{@link org.eclipse.e4.emf.xpath.test.model.xpathtest.impl.NodeImpl#getMenus <em>Menus</em>}</li> 41 * <li>{@link org.eclipse.e4.emf.xpath.test.model.xpathtest.impl.NodeImpl#getParent <em>Parent</em>}</li> 42 * <li>{@link org.eclipse.e4.emf.xpath.test.model.xpathtest.impl.NodeImpl#getChildren <em>Children</em>}</li> 43 * <li>{@link org.eclipse.e4.emf.xpath.test.model.xpathtest.impl.NodeImpl#getRoot <em>Root</em>}</li> 44 * <li>{@link org.eclipse.e4.emf.xpath.test.model.xpathtest.impl.NodeImpl#getCat <em>Cat</em>}</li> 45 * <li>{@link org.eclipse.e4.emf.xpath.test.model.xpathtest.impl.NodeImpl#getValue <em>Value</em>}</li> 46 * <li>{@link org.eclipse.e4.emf.xpath.test.model.xpathtest.impl.NodeImpl#getId <em>Id</em>}</li> 47 * <li>{@link org.eclipse.e4.emf.xpath.test.model.xpathtest.impl.NodeImpl#getInrefs <em>Inrefs</em>}</li> 48 * <li>{@link org.eclipse.e4.emf.xpath.test.model.xpathtest.impl.NodeImpl#getOutrefs <em>Outrefs</em>}</li> 49 * </ul> 50 * </p> 51 * 52 * @generated 53 */ 54 public class NodeImpl extends EObjectImpl implements Node { 55 /** 56 * The cached value of the '{@link #getMenus() <em>Menus</em>}' containment reference list. 57 * <!-- begin-user-doc --> 58 * <!-- end-user-doc --> 59 * @see #getMenus() 60 * @generated 61 * @ordered 62 */ 63 protected EList<MenuElement> menus; 64 65 /** 66 * The cached value of the '{@link #getChildren() <em>Children</em>}' containment reference list. 67 * <!-- begin-user-doc --> 68 * <!-- end-user-doc --> 69 * @see #getChildren() 70 * @generated 71 * @ordered 72 */ 73 protected EList<Node> children; 74 75 /** 76 * The cached value of the '{@link #getRoot() <em>Root</em>}' reference. 77 * <!-- begin-user-doc --> 78 * <!-- end-user-doc --> 79 * @see #getRoot() 80 * @generated 81 * @ordered 82 */ 83 protected Root root; 84 85 /** 86 * The default value of the '{@link #getCat() <em>Cat</em>}' attribute. 87 * <!-- begin-user-doc --> 88 * <!-- end-user-doc --> 89 * @see #getCat() 90 * @generated 91 * @ordered 92 */ 93 protected static final String CAT_EDEFAULT = null; 94 95 /** 96 * The cached value of the '{@link #getCat() <em>Cat</em>}' attribute. 97 * <!-- begin-user-doc --> 98 * <!-- end-user-doc --> 99 * @see #getCat() 100 * @generated 101 * @ordered 102 */ 103 protected String cat = CAT_EDEFAULT; 104 105 /** 106 * The default value of the '{@link #getValue() <em>Value</em>}' attribute. 107 * <!-- begin-user-doc --> 108 * <!-- end-user-doc --> 109 * @see #getValue() 110 * @generated 111 * @ordered 112 */ 113 protected static final String VALUE_EDEFAULT = null; 114 115 /** 116 * The cached value of the '{@link #getValue() <em>Value</em>}' attribute. 117 * <!-- begin-user-doc --> 118 * <!-- end-user-doc --> 119 * @see #getValue() 120 * @generated 121 * @ordered 122 */ 123 protected String value = VALUE_EDEFAULT; 124 125 /** 126 * The default value of the '{@link #getId() <em>Id</em>}' attribute. 127 * <!-- begin-user-doc --> 128 * <!-- end-user-doc --> 129 * @see #getId() 130 * @generated 131 * @ordered 132 */ 133 protected static final String ID_EDEFAULT = null; 134 135 /** 136 * The cached value of the '{@link #getId() <em>Id</em>}' attribute. 137 * <!-- begin-user-doc --> 138 * <!-- end-user-doc --> 139 * @see #getId() 140 * @generated 141 * @ordered 142 */ 143 protected String id = ID_EDEFAULT; 144 145 /** 146 * The cached value of the '{@link #getInrefs() <em>Inrefs</em>}' reference list. 147 * <!-- begin-user-doc --> 148 * <!-- end-user-doc --> 149 * @see #getInrefs() 150 * @generated 151 * @ordered 152 */ 153 protected EList<Node> inrefs; 154 155 /** 156 * The cached value of the '{@link #getOutrefs() <em>Outrefs</em>}' reference list. 157 * <!-- begin-user-doc --> 158 * <!-- end-user-doc --> 159 * @see #getOutrefs() 160 * @generated 161 * @ordered 162 */ 163 protected EList<Node> outrefs; 164 165 /** 166 * <!-- begin-user-doc --> 167 * <!-- end-user-doc --> 168 * @generated 169 */ NodeImpl()170 protected NodeImpl() { 171 super(); 172 } 173 174 /** 175 * <!-- begin-user-doc --> 176 * <!-- end-user-doc --> 177 * @generated 178 */ 179 @Override eStaticClass()180 protected EClass eStaticClass() { 181 return XpathtestPackage.Literals.NODE; 182 } 183 184 /** 185 * <!-- begin-user-doc --> 186 * <!-- end-user-doc --> 187 * @generated 188 */ 189 @Override getMenus()190 public EList<MenuElement> getMenus() { 191 if (menus == null) { 192 menus = new EObjectContainmentEList<>(MenuElement.class, this, XpathtestPackage.NODE__MENUS); 193 } 194 return menus; 195 } 196 197 /** 198 * <!-- begin-user-doc --> 199 * <!-- end-user-doc --> 200 * @generated 201 */ 202 @Override getParent()203 public Node getParent() { 204 if (eContainerFeatureID() != XpathtestPackage.NODE__PARENT) return null; 205 return (Node)eInternalContainer(); 206 } 207 208 /** 209 * <!-- begin-user-doc --> 210 * <!-- end-user-doc --> 211 * @generated 212 */ basicSetParent(Node newParent, NotificationChain msgs)213 public NotificationChain basicSetParent(Node newParent, NotificationChain msgs) { 214 return eBasicSetContainer((InternalEObject)newParent, XpathtestPackage.NODE__PARENT, msgs); 215 } 216 217 /** 218 * <!-- begin-user-doc --> 219 * <!-- end-user-doc --> 220 * @generated 221 */ 222 @Override setParent(Node newParent)223 public void setParent(Node newParent) { 224 if (newParent != eInternalContainer() || (eContainerFeatureID() != XpathtestPackage.NODE__PARENT && newParent != null)) { 225 if (EcoreUtil.isAncestor(this, newParent)) 226 throw new IllegalArgumentException("Recursive containment not allowed for " + this); 227 NotificationChain msgs = null; 228 if (eInternalContainer() != null) 229 msgs = eBasicRemoveFromContainer(msgs); 230 if (newParent != null) 231 msgs = ((InternalEObject)newParent).eInverseAdd(this, XpathtestPackage.NODE__CHILDREN, Node.class, msgs); 232 msgs = basicSetParent(newParent, msgs); 233 if (msgs != null) msgs.dispatch(); 234 } 235 else if (eNotificationRequired()) 236 eNotify(new ENotificationImpl(this, Notification.SET, XpathtestPackage.NODE__PARENT, newParent, newParent)); 237 } 238 239 /** 240 * <!-- begin-user-doc --> 241 * <!-- end-user-doc --> 242 * @generated 243 */ 244 @Override getChildren()245 public EList<Node> getChildren() { 246 if (children == null) { 247 children = new EObjectContainmentWithInverseEList<>(Node.class, this, XpathtestPackage.NODE__CHILDREN, XpathtestPackage.NODE__PARENT); 248 } 249 return children; 250 } 251 252 /** 253 * <!-- begin-user-doc --> 254 * <!-- end-user-doc --> 255 * @generated 256 */ 257 @Override getRoot()258 public Root getRoot() { 259 if (root != null && root.eIsProxy()) { 260 InternalEObject oldRoot = (InternalEObject)root; 261 root = (Root)eResolveProxy(oldRoot); 262 if (root != oldRoot) { 263 if (eNotificationRequired()) 264 eNotify(new ENotificationImpl(this, Notification.RESOLVE, XpathtestPackage.NODE__ROOT, oldRoot, root)); 265 } 266 } 267 return root; 268 } 269 270 /** 271 * <!-- begin-user-doc --> 272 * <!-- end-user-doc --> 273 * @generated 274 */ basicGetRoot()275 public Root basicGetRoot() { 276 return root; 277 } 278 279 /** 280 * <!-- begin-user-doc --> 281 * <!-- end-user-doc --> 282 * @generated 283 */ 284 @Override setRoot(Root newRoot)285 public void setRoot(Root newRoot) { 286 Root oldRoot = root; 287 root = newRoot; 288 if (eNotificationRequired()) 289 eNotify(new ENotificationImpl(this, Notification.SET, XpathtestPackage.NODE__ROOT, oldRoot, root)); 290 } 291 292 /** 293 * <!-- begin-user-doc --> 294 * <!-- end-user-doc --> 295 * @generated 296 */ 297 @Override getCat()298 public String getCat() { 299 return cat; 300 } 301 302 /** 303 * <!-- begin-user-doc --> 304 * <!-- end-user-doc --> 305 * @generated 306 */ 307 @Override setCat(String newCat)308 public void setCat(String newCat) { 309 String oldCat = cat; 310 cat = newCat; 311 if (eNotificationRequired()) 312 eNotify(new ENotificationImpl(this, Notification.SET, XpathtestPackage.NODE__CAT, oldCat, cat)); 313 } 314 315 /** 316 * <!-- begin-user-doc --> 317 * <!-- end-user-doc --> 318 * @generated 319 */ 320 @Override getValue()321 public String getValue() { 322 return value; 323 } 324 325 /** 326 * <!-- begin-user-doc --> 327 * <!-- end-user-doc --> 328 * @generated 329 */ 330 @Override setValue(String newValue)331 public void setValue(String newValue) { 332 String oldValue = value; 333 value = newValue; 334 if (eNotificationRequired()) 335 eNotify(new ENotificationImpl(this, Notification.SET, XpathtestPackage.NODE__VALUE, oldValue, value)); 336 } 337 338 /** 339 * <!-- begin-user-doc --> 340 * <!-- end-user-doc --> 341 * @generated 342 */ 343 @Override getId()344 public String getId() { 345 return id; 346 } 347 348 /** 349 * <!-- begin-user-doc --> 350 * <!-- end-user-doc --> 351 * @generated 352 */ 353 @Override setId(String newId)354 public void setId(String newId) { 355 String oldId = id; 356 id = newId; 357 if (eNotificationRequired()) 358 eNotify(new ENotificationImpl(this, Notification.SET, XpathtestPackage.NODE__ID, oldId, id)); 359 } 360 361 /** 362 * <!-- begin-user-doc --> 363 * <!-- end-user-doc --> 364 * @generated 365 */ 366 @Override getInrefs()367 public EList<Node> getInrefs() { 368 if (inrefs == null) { 369 inrefs = new EObjectWithInverseResolvingEList.ManyInverse<>(Node.class, this, XpathtestPackage.NODE__INREFS, XpathtestPackage.NODE__OUTREFS); 370 } 371 return inrefs; 372 } 373 374 /** 375 * <!-- begin-user-doc --> 376 * <!-- end-user-doc --> 377 * @generated 378 */ 379 @Override getOutrefs()380 public EList<Node> getOutrefs() { 381 if (outrefs == null) { 382 outrefs = new EObjectWithInverseResolvingEList.ManyInverse<>(Node.class, this, XpathtestPackage.NODE__OUTREFS, XpathtestPackage.NODE__INREFS); 383 } 384 return outrefs; 385 } 386 387 /** 388 * <!-- begin-user-doc --> 389 * <!-- end-user-doc --> 390 * @generated 391 */ 392 @SuppressWarnings("unchecked") 393 @Override eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs)394 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { 395 switch (featureID) { 396 case XpathtestPackage.NODE__PARENT: 397 if (eInternalContainer() != null) 398 msgs = eBasicRemoveFromContainer(msgs); 399 return basicSetParent((Node)otherEnd, msgs); 400 case XpathtestPackage.NODE__CHILDREN: 401 return ((InternalEList<InternalEObject>)(InternalEList<?>)getChildren()).basicAdd(otherEnd, msgs); 402 case XpathtestPackage.NODE__INREFS: 403 return ((InternalEList<InternalEObject>)(InternalEList<?>)getInrefs()).basicAdd(otherEnd, msgs); 404 case XpathtestPackage.NODE__OUTREFS: 405 return ((InternalEList<InternalEObject>)(InternalEList<?>)getOutrefs()).basicAdd(otherEnd, msgs); 406 } 407 return super.eInverseAdd(otherEnd, featureID, msgs); 408 } 409 410 /** 411 * <!-- begin-user-doc --> 412 * <!-- end-user-doc --> 413 * @generated 414 */ 415 @Override eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)416 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { 417 switch (featureID) { 418 case XpathtestPackage.NODE__MENUS: 419 return ((InternalEList<?>)getMenus()).basicRemove(otherEnd, msgs); 420 case XpathtestPackage.NODE__PARENT: 421 return basicSetParent(null, msgs); 422 case XpathtestPackage.NODE__CHILDREN: 423 return ((InternalEList<?>)getChildren()).basicRemove(otherEnd, msgs); 424 case XpathtestPackage.NODE__INREFS: 425 return ((InternalEList<?>)getInrefs()).basicRemove(otherEnd, msgs); 426 case XpathtestPackage.NODE__OUTREFS: 427 return ((InternalEList<?>)getOutrefs()).basicRemove(otherEnd, msgs); 428 } 429 return super.eInverseRemove(otherEnd, featureID, msgs); 430 } 431 432 /** 433 * <!-- begin-user-doc --> 434 * <!-- end-user-doc --> 435 * @generated 436 */ 437 @Override eBasicRemoveFromContainerFeature(NotificationChain msgs)438 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { 439 switch (eContainerFeatureID()) { 440 case XpathtestPackage.NODE__PARENT: 441 return eInternalContainer().eInverseRemove(this, XpathtestPackage.NODE__CHILDREN, Node.class, msgs); 442 } 443 return super.eBasicRemoveFromContainerFeature(msgs); 444 } 445 446 /** 447 * <!-- begin-user-doc --> 448 * <!-- end-user-doc --> 449 * @generated 450 */ 451 @Override eGet(int featureID, boolean resolve, boolean coreType)452 public Object eGet(int featureID, boolean resolve, boolean coreType) { 453 switch (featureID) { 454 case XpathtestPackage.NODE__MENUS: 455 return getMenus(); 456 case XpathtestPackage.NODE__PARENT: 457 return getParent(); 458 case XpathtestPackage.NODE__CHILDREN: 459 return getChildren(); 460 case XpathtestPackage.NODE__ROOT: 461 if (resolve) return getRoot(); 462 return basicGetRoot(); 463 case XpathtestPackage.NODE__CAT: 464 return getCat(); 465 case XpathtestPackage.NODE__VALUE: 466 return getValue(); 467 case XpathtestPackage.NODE__ID: 468 return getId(); 469 case XpathtestPackage.NODE__INREFS: 470 return getInrefs(); 471 case XpathtestPackage.NODE__OUTREFS: 472 return getOutrefs(); 473 } 474 return super.eGet(featureID, resolve, coreType); 475 } 476 477 /** 478 * <!-- begin-user-doc --> 479 * <!-- end-user-doc --> 480 * @generated 481 */ 482 @SuppressWarnings("unchecked") 483 @Override eSet(int featureID, Object newValue)484 public void eSet(int featureID, Object newValue) { 485 switch (featureID) { 486 case XpathtestPackage.NODE__MENUS: 487 getMenus().clear(); 488 getMenus().addAll((Collection<? extends MenuElement>)newValue); 489 return; 490 case XpathtestPackage.NODE__PARENT: 491 setParent((Node)newValue); 492 return; 493 case XpathtestPackage.NODE__CHILDREN: 494 getChildren().clear(); 495 getChildren().addAll((Collection<? extends Node>)newValue); 496 return; 497 case XpathtestPackage.NODE__ROOT: 498 setRoot((Root)newValue); 499 return; 500 case XpathtestPackage.NODE__CAT: 501 setCat((String)newValue); 502 return; 503 case XpathtestPackage.NODE__VALUE: 504 setValue((String)newValue); 505 return; 506 case XpathtestPackage.NODE__ID: 507 setId((String)newValue); 508 return; 509 case XpathtestPackage.NODE__INREFS: 510 getInrefs().clear(); 511 getInrefs().addAll((Collection<? extends Node>)newValue); 512 return; 513 case XpathtestPackage.NODE__OUTREFS: 514 getOutrefs().clear(); 515 getOutrefs().addAll((Collection<? extends Node>)newValue); 516 return; 517 } 518 super.eSet(featureID, newValue); 519 } 520 521 /** 522 * <!-- begin-user-doc --> 523 * <!-- end-user-doc --> 524 * @generated 525 */ 526 @Override eUnset(int featureID)527 public void eUnset(int featureID) { 528 switch (featureID) { 529 case XpathtestPackage.NODE__MENUS: 530 getMenus().clear(); 531 return; 532 case XpathtestPackage.NODE__PARENT: 533 setParent((Node)null); 534 return; 535 case XpathtestPackage.NODE__CHILDREN: 536 getChildren().clear(); 537 return; 538 case XpathtestPackage.NODE__ROOT: 539 setRoot((Root)null); 540 return; 541 case XpathtestPackage.NODE__CAT: 542 setCat(CAT_EDEFAULT); 543 return; 544 case XpathtestPackage.NODE__VALUE: 545 setValue(VALUE_EDEFAULT); 546 return; 547 case XpathtestPackage.NODE__ID: 548 setId(ID_EDEFAULT); 549 return; 550 case XpathtestPackage.NODE__INREFS: 551 getInrefs().clear(); 552 return; 553 case XpathtestPackage.NODE__OUTREFS: 554 getOutrefs().clear(); 555 return; 556 } 557 super.eUnset(featureID); 558 } 559 560 /** 561 * <!-- begin-user-doc --> 562 * <!-- end-user-doc --> 563 * @generated 564 */ 565 @Override eIsSet(int featureID)566 public boolean eIsSet(int featureID) { 567 switch (featureID) { 568 case XpathtestPackage.NODE__MENUS: 569 return menus != null && !menus.isEmpty(); 570 case XpathtestPackage.NODE__PARENT: 571 return getParent() != null; 572 case XpathtestPackage.NODE__CHILDREN: 573 return children != null && !children.isEmpty(); 574 case XpathtestPackage.NODE__ROOT: 575 return root != null; 576 case XpathtestPackage.NODE__CAT: 577 return CAT_EDEFAULT == null ? cat != null : !CAT_EDEFAULT.equals(cat); 578 case XpathtestPackage.NODE__VALUE: 579 return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value); 580 case XpathtestPackage.NODE__ID: 581 return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); 582 case XpathtestPackage.NODE__INREFS: 583 return inrefs != null && !inrefs.isEmpty(); 584 case XpathtestPackage.NODE__OUTREFS: 585 return outrefs != null && !outrefs.isEmpty(); 586 } 587 return super.eIsSet(featureID); 588 } 589 590 /** 591 * <!-- begin-user-doc --> 592 * <!-- end-user-doc --> 593 * @generated 594 */ 595 @Override toString()596 public String toString() { 597 if (eIsProxy()) return super.toString(); 598 599 StringBuilder result = new StringBuilder(super.toString()); 600 result.append(" (cat: "); 601 result.append(cat); 602 result.append(", value: "); 603 result.append(value); 604 result.append(", id: "); 605 result.append(id); 606 result.append(')'); 607 return result.toString(); 608 } 609 610 } //NodeImpl 611