/**
* <copyright>
* </copyright>
*
* $Id$
*/
package orgomg.cwm.analysis.businessnomenclature.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.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import orgomg.cwm.analysis.businessnomenclature.BusinessnomenclaturePackage;
import orgomg.cwm.analysis.businessnomenclature.Nomenclature;
import orgomg.cwm.objectmodel.core.impl.PackageImpl;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Nomenclature</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link orgomg.cwm.analysis.businessnomenclature.impl.NomenclatureImpl#getParent <em>Parent</em>}</li>
* <li>{@link orgomg.cwm.analysis.businessnomenclature.impl.NomenclatureImpl#getChild <em>Child</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class NomenclatureImpl extends PackageImpl implements Nomenclature {
/**
* The cached value of the '{@link #getChild() <em>Child</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getChild()
* @generated
* @ordered
*/
protected EList<Nomenclature> child;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected NomenclatureImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return BusinessnomenclaturePackage.Literals.NOMENCLATURE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Nomenclature getParent() {
if (eContainerFeatureID() != BusinessnomenclaturePackage.NOMENCLATURE__PARENT) return null;
return (Nomenclature)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetParent(Nomenclature newParent, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newParent, BusinessnomenclaturePackage.NOMENCLATURE__PARENT, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setParent(Nomenclature newParent) {
if (newParent != eInternalContainer() || (eContainerFeatureID() != BusinessnomenclaturePackage.NOMENCLATURE__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, BusinessnomenclaturePackage.NOMENCLATURE__CHILD, Nomenclature.class, msgs);
msgs = basicSetParent(newParent, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, BusinessnomenclaturePackage.NOMENCLATURE__PARENT, newParent, newParent));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Nomenclature> getChild() {
if (child == null) {
child = new EObjectContainmentWithInverseEList<Nomenclature>(Nomenclature.class, this, BusinessnomenclaturePackage.NOMENCLATURE__CHILD, BusinessnomenclaturePackage.NOMENCLATURE__PARENT);
}
return child;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case BusinessnomenclaturePackage.NOMENCLATURE__PARENT:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetParent((Nomenclature)otherEnd, msgs);
case BusinessnomenclaturePackage.NOMENCLATURE__CHILD:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getChild()).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 BusinessnomenclaturePackage.NOMENCLATURE__PARENT:
return basicSetParent(null, msgs);
case BusinessnomenclaturePackage.NOMENCLATURE__CHILD:
return ((InternalEList<?>)getChild()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case BusinessnomenclaturePackage.NOMENCLATURE__PARENT:
return eInternalContainer().eInverseRemove(this, BusinessnomenclaturePackage.NOMENCLATURE__CHILD, Nomenclature.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 BusinessnomenclaturePackage.NOMENCLATURE__PARENT:
return getParent();
case BusinessnomenclaturePackage.NOMENCLATURE__CHILD:
return getChild();
}
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 BusinessnomenclaturePackage.NOMENCLATURE__PARENT:
setParent((Nomenclature)newValue);
return;
case BusinessnomenclaturePackage.NOMENCLATURE__CHILD:
getChild().clear();
getChild().addAll((Collection<? extends Nomenclature>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case BusinessnomenclaturePackage.NOMENCLATURE__PARENT:
setParent((Nomenclature)null);
return;
case BusinessnomenclaturePackage.NOMENCLATURE__CHILD:
getChild().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case BusinessnomenclaturePackage.NOMENCLATURE__PARENT:
return getParent() != null;
case BusinessnomenclaturePackage.NOMENCLATURE__CHILD:
return child != null && !child.isEmpty();
}
return super.eIsSet(featureID);
}
} //NomenclatureImpl