/*******************************************************************************
* Copyright (c) 2010-2015 Henshin developers. 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:
* TU Berlin, University of Luxembourg, SES S.A.
*******************************************************************************/
package de.tub.tfs.henshin.model.subtree.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.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.emf.henshin.model.Node;
import de.tub.tfs.henshin.model.subtree.Edge;
import de.tub.tfs.henshin.model.subtree.Subtree;
import de.tub.tfs.henshin.model.subtree.SubtreePackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Subtree</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link de.tub.tfs.henshin.model.subtree.impl.SubtreeImpl#getIncoming <em>Incoming</em>}</li>
* <li>{@link de.tub.tfs.henshin.model.subtree.impl.SubtreeImpl#getOutgoing <em>Outgoing</em>}</li>
* <li>{@link de.tub.tfs.henshin.model.subtree.impl.SubtreeImpl#getRoot <em>Root</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class SubtreeImpl extends EObjectImpl implements Subtree {
/**
* The cached value of the '{@link #getIncoming() <em>Incoming</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getIncoming()
* @generated
* @ordered
*/
protected EList<Edge> incoming;
/**
* The cached value of the '{@link #getOutgoing() <em>Outgoing</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOutgoing()
* @generated
* @ordered
*/
protected EList<Edge> outgoing;
/**
* The cached value of the '{@link #getRoot() <em>Root</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getRoot()
* @generated
* @ordered
*/
protected Node root;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected SubtreeImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return SubtreePackage.Literals.SUBTREE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Edge> getIncoming() {
if (incoming == null) {
incoming = new EObjectWithInverseResolvingEList<Edge>(Edge.class, this, SubtreePackage.SUBTREE__INCOMING, SubtreePackage.EDGE__TARGET);
}
return incoming;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Edge> getOutgoing() {
if (outgoing == null) {
outgoing = new EObjectWithInverseResolvingEList<Edge>(Edge.class, this, SubtreePackage.SUBTREE__OUTGOING, SubtreePackage.EDGE__SOURCE);
}
return outgoing;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Node getRoot() {
if (root != null && root.eIsProxy()) {
InternalEObject oldRoot = (InternalEObject)root;
root = (Node)eResolveProxy(oldRoot);
if (root != oldRoot) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, SubtreePackage.SUBTREE__ROOT, oldRoot, root));
}
}
return root;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Node basicGetRoot() {
return root;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setRoot(Node newRoot) {
Node oldRoot = root;
root = newRoot;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SubtreePackage.SUBTREE__ROOT, oldRoot, root));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case SubtreePackage.SUBTREE__INCOMING:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getIncoming()).basicAdd(otherEnd, msgs);
case SubtreePackage.SUBTREE__OUTGOING:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getOutgoing()).basicAdd(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 SubtreePackage.SUBTREE__INCOMING:
return ((InternalEList<?>)getIncoming()).basicRemove(otherEnd, msgs);
case SubtreePackage.SUBTREE__OUTGOING:
return ((InternalEList<?>)getOutgoing()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case SubtreePackage.SUBTREE__INCOMING:
return getIncoming();
case SubtreePackage.SUBTREE__OUTGOING:
return getOutgoing();
case SubtreePackage.SUBTREE__ROOT:
if (resolve) return getRoot();
return basicGetRoot();
}
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 SubtreePackage.SUBTREE__INCOMING:
getIncoming().clear();
getIncoming().addAll((Collection<? extends Edge>)newValue);
return;
case SubtreePackage.SUBTREE__OUTGOING:
getOutgoing().clear();
getOutgoing().addAll((Collection<? extends Edge>)newValue);
return;
case SubtreePackage.SUBTREE__ROOT:
setRoot((Node)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case SubtreePackage.SUBTREE__INCOMING:
getIncoming().clear();
return;
case SubtreePackage.SUBTREE__OUTGOING:
getOutgoing().clear();
return;
case SubtreePackage.SUBTREE__ROOT:
setRoot((Node)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case SubtreePackage.SUBTREE__INCOMING:
return incoming != null && !incoming.isEmpty();
case SubtreePackage.SUBTREE__OUTGOING:
return outgoing != null && !outgoing.isEmpty();
case SubtreePackage.SUBTREE__ROOT:
return root != null;
}
return super.eIsSet(featureID);
}
} //SubtreeImpl