blob: 7e093100b08d8b32e97a6d3f4172899fdafbc402 [file] [log] [blame]
/**
* Copyright (c) 2015, 2016 Willink Transformations and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* E.D.Willink - Initial API and implementation
*/
package tree2talltree.talltree.impl;
import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import tree2talltree.talltree.TallNode;
import tree2talltree.talltree.TalltreePackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Tall Node</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link tree2talltree.talltree.impl.TallNodeImpl#getChildren <em>Children</em>}</li>
* <li>{@link tree2talltree.talltree.impl.TallNodeImpl#getHeight <em>Height</em>}</li>
* <li>{@link tree2talltree.talltree.impl.TallNodeImpl#getName <em>Name</em>}</li>
* <li>{@link tree2talltree.talltree.impl.TallNodeImpl#getParent <em>Parent</em>}</li>
* </ul>
*
* @generated
*/
public class TallNodeImpl extends MinimalEObjectImpl.Container implements TallNode {
/**
* The cached value of the '{@link #getChildren() <em>Children</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getChildren()
* @generated
* @ordered
*/
protected EList<TallNode> children;
/**
* The default value of the '{@link #getHeight() <em>Height</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getHeight()
* @generated
* @ordered
*/
protected static final int HEIGHT_EDEFAULT = 0;
/**
* The cached value of the '{@link #getHeight() <em>Height</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getHeight()
* @generated
* @ordered
*/
protected int height = HEIGHT_EDEFAULT;
/**
* The default value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected static final String NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected String name = NAME_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected TallNodeImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return TalltreePackage.Literals.TALL_NODE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<TallNode> getChildren() {
if (children == null) {
children = new EObjectContainmentWithInverseEList<TallNode>(TallNode.class, this, TalltreePackage.TALL_NODE__CHILDREN, TalltreePackage.TALL_NODE__PARENT);
}
return children;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int getHeight() {
return height;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setHeight(int newHeight) {
int oldHeight = height;
height = newHeight;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, TalltreePackage.TALL_NODE__HEIGHT, oldHeight, height));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String getName() {
return name;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setName(String newName) {
String oldName = name;
name = newName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, TalltreePackage.TALL_NODE__NAME, oldName, name));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public TallNode getParent() {
if (eContainerFeatureID() != TalltreePackage.TALL_NODE__PARENT) return null;
return (TallNode)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetParent(TallNode newParent, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newParent, TalltreePackage.TALL_NODE__PARENT, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setParent(TallNode newParent) {
if (newParent != eInternalContainer() || (eContainerFeatureID() != TalltreePackage.TALL_NODE__PARENT && newParent != null)) {
if (EcoreUtil.isAncestor(this, newParent))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newParent != null)
msgs = ((InternalEObject)newParent).eInverseAdd(this, TalltreePackage.TALL_NODE__CHILDREN, TallNode.class, msgs);
msgs = basicSetParent(newParent, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, TalltreePackage.TALL_NODE__PARENT, newParent, newParent));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case TalltreePackage.TALL_NODE__CHILDREN:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getChildren()).basicAdd(otherEnd, msgs);
case TalltreePackage.TALL_NODE__PARENT:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetParent((TallNode)otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case TalltreePackage.TALL_NODE__CHILDREN:
return ((InternalEList<?>)getChildren()).basicRemove(otherEnd, msgs);
case TalltreePackage.TALL_NODE__PARENT:
return basicSetParent(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case TalltreePackage.TALL_NODE__PARENT:
return eInternalContainer().eInverseRemove(this, TalltreePackage.TALL_NODE__CHILDREN, TallNode.class, msgs);
}
return super.eBasicRemoveFromContainerFeature(msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case TalltreePackage.TALL_NODE__CHILDREN:
return getChildren();
case TalltreePackage.TALL_NODE__HEIGHT:
return getHeight();
case TalltreePackage.TALL_NODE__NAME:
return getName();
case TalltreePackage.TALL_NODE__PARENT:
return getParent();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case TalltreePackage.TALL_NODE__CHILDREN:
getChildren().clear();
getChildren().addAll((Collection<? extends TallNode>)newValue);
return;
case TalltreePackage.TALL_NODE__HEIGHT:
setHeight((Integer)newValue);
return;
case TalltreePackage.TALL_NODE__NAME:
setName((String)newValue);
return;
case TalltreePackage.TALL_NODE__PARENT:
setParent((TallNode)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case TalltreePackage.TALL_NODE__CHILDREN:
getChildren().clear();
return;
case TalltreePackage.TALL_NODE__HEIGHT:
setHeight(HEIGHT_EDEFAULT);
return;
case TalltreePackage.TALL_NODE__NAME:
setName(NAME_EDEFAULT);
return;
case TalltreePackage.TALL_NODE__PARENT:
setParent((TallNode)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case TalltreePackage.TALL_NODE__CHILDREN:
return children != null && !children.isEmpty();
case TalltreePackage.TALL_NODE__HEIGHT:
return height != HEIGHT_EDEFAULT;
case TalltreePackage.TALL_NODE__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case TalltreePackage.TALL_NODE__PARENT:
return getParent() != null;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (height: ");
result.append(height);
result.append(", name: ");
result.append(name);
result.append(')');
return result.toString();
}
} //TallNodeImpl