/**
*/
package fr.inria.diverse.melange.metamodel.melange.impl;
import fr.inria.diverse.melange.metamodel.melange.MelangePackage;
import fr.inria.diverse.melange.metamodel.melange.ModelType;
import fr.inria.diverse.melange.metamodel.melange.Subtyping;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
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.EcoreUtil;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Subtyping</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link fr.inria.diverse.melange.metamodel.melange.impl.SubtypingImpl#getSubType <em>Sub Type</em>}</li>
* <li>{@link fr.inria.diverse.melange.metamodel.melange.impl.SubtypingImpl#getSuperType <em>Super Type</em>}</li>
* </ul>
*
* @generated
*/
public class SubtypingImpl extends MinimalEObjectImpl.Container implements Subtyping {
/**
* The cached value of the '{@link #getSuperType() <em>Super Type</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSuperType()
* @generated
* @ordered
*/
protected ModelType superType;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected SubtypingImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return MelangePackage.Literals.SUBTYPING;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ModelType getSubType() {
if (eContainerFeatureID() != MelangePackage.SUBTYPING__SUB_TYPE) return null;
return (ModelType)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetSubType(ModelType newSubType, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newSubType, MelangePackage.SUBTYPING__SUB_TYPE, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSubType(ModelType newSubType) {
if (newSubType != eInternalContainer() || (eContainerFeatureID() != MelangePackage.SUBTYPING__SUB_TYPE && newSubType != null)) {
if (EcoreUtil.isAncestor(this, newSubType))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newSubType != null)
msgs = ((InternalEObject)newSubType).eInverseAdd(this, MelangePackage.MODEL_TYPE__SUBTYPING_RELATIONS, ModelType.class, msgs);
msgs = basicSetSubType(newSubType, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MelangePackage.SUBTYPING__SUB_TYPE, newSubType, newSubType));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ModelType getSuperType() {
if (superType != null && superType.eIsProxy()) {
InternalEObject oldSuperType = (InternalEObject)superType;
superType = (ModelType)eResolveProxy(oldSuperType);
if (superType != oldSuperType) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, MelangePackage.SUBTYPING__SUPER_TYPE, oldSuperType, superType));
}
}
return superType;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ModelType basicGetSuperType() {
return superType;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSuperType(ModelType newSuperType) {
ModelType oldSuperType = superType;
superType = newSuperType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MelangePackage.SUBTYPING__SUPER_TYPE, oldSuperType, superType));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case MelangePackage.SUBTYPING__SUB_TYPE:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetSubType((ModelType)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 MelangePackage.SUBTYPING__SUB_TYPE:
return basicSetSubType(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case MelangePackage.SUBTYPING__SUB_TYPE:
return eInternalContainer().eInverseRemove(this, MelangePackage.MODEL_TYPE__SUBTYPING_RELATIONS, ModelType.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 MelangePackage.SUBTYPING__SUB_TYPE:
return getSubType();
case MelangePackage.SUBTYPING__SUPER_TYPE:
if (resolve) return getSuperType();
return basicGetSuperType();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case MelangePackage.SUBTYPING__SUB_TYPE:
setSubType((ModelType)newValue);
return;
case MelangePackage.SUBTYPING__SUPER_TYPE:
setSuperType((ModelType)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case MelangePackage.SUBTYPING__SUB_TYPE:
setSubType((ModelType)null);
return;
case MelangePackage.SUBTYPING__SUPER_TYPE:
setSuperType((ModelType)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case MelangePackage.SUBTYPING__SUB_TYPE:
return getSubType() != null;
case MelangePackage.SUBTYPING__SUPER_TYPE:
return superType != null;
}
return super.eIsSet(featureID);
}
} //SubtypingImpl