/**
* <copyright>
* </copyright>
*
* $Id$
*/
package orgomg.cwm.objectmodel.instance.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.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;
import orgomg.cwm.objectmodel.core.Classifier;
import orgomg.cwm.objectmodel.core.CorePackage;
import orgomg.cwm.objectmodel.core.impl.ModelElementImpl;
import orgomg.cwm.objectmodel.instance.Instance;
import orgomg.cwm.objectmodel.instance.InstancePackage;
import orgomg.cwm.objectmodel.instance.Slot;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Instance</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link orgomg.cwm.objectmodel.instance.impl.InstanceImpl#getValueSlot <em>Value Slot</em>}</li>
* <li>{@link orgomg.cwm.objectmodel.instance.impl.InstanceImpl#getClassifier <em>Classifier</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public abstract class InstanceImpl extends ModelElementImpl implements Instance {
/**
* The cached value of the '{@link #getValueSlot() <em>Value Slot</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getValueSlot()
* @generated
* @ordered
*/
protected EList<Slot> valueSlot;
/**
* The cached value of the '{@link #getClassifier() <em>Classifier</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getClassifier()
* @generated
* @ordered
*/
protected Classifier classifier;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected InstanceImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return InstancePackage.Literals.INSTANCE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Slot> getValueSlot() {
if (valueSlot == null) {
valueSlot = new EObjectWithInverseResolvingEList<Slot>(Slot.class, this, InstancePackage.INSTANCE__VALUE_SLOT, InstancePackage.SLOT__VALUE);
}
return valueSlot;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Classifier getClassifier() {
if (classifier != null && classifier.eIsProxy()) {
InternalEObject oldClassifier = (InternalEObject)classifier;
classifier = (Classifier)eResolveProxy(oldClassifier);
if (classifier != oldClassifier) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, InstancePackage.INSTANCE__CLASSIFIER, oldClassifier, classifier));
}
}
return classifier;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Classifier basicGetClassifier() {
return classifier;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetClassifier(Classifier newClassifier, NotificationChain msgs) {
Classifier oldClassifier = classifier;
classifier = newClassifier;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, InstancePackage.INSTANCE__CLASSIFIER, oldClassifier, newClassifier);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setClassifier(Classifier newClassifier) {
if (newClassifier != classifier) {
NotificationChain msgs = null;
if (classifier != null)
msgs = ((InternalEObject)classifier).eInverseRemove(this, CorePackage.CLASSIFIER__INSTANCE, Classifier.class, msgs);
if (newClassifier != null)
msgs = ((InternalEObject)newClassifier).eInverseAdd(this, CorePackage.CLASSIFIER__INSTANCE, Classifier.class, msgs);
msgs = basicSetClassifier(newClassifier, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, InstancePackage.INSTANCE__CLASSIFIER, newClassifier, newClassifier));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case InstancePackage.INSTANCE__VALUE_SLOT:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getValueSlot()).basicAdd(otherEnd, msgs);
case InstancePackage.INSTANCE__CLASSIFIER:
if (classifier != null)
msgs = ((InternalEObject)classifier).eInverseRemove(this, CorePackage.CLASSIFIER__INSTANCE, Classifier.class, msgs);
return basicSetClassifier((Classifier)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 InstancePackage.INSTANCE__VALUE_SLOT:
return ((InternalEList<?>)getValueSlot()).basicRemove(otherEnd, msgs);
case InstancePackage.INSTANCE__CLASSIFIER:
return basicSetClassifier(null, 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 InstancePackage.INSTANCE__VALUE_SLOT:
return getValueSlot();
case InstancePackage.INSTANCE__CLASSIFIER:
if (resolve) return getClassifier();
return basicGetClassifier();
}
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 InstancePackage.INSTANCE__VALUE_SLOT:
getValueSlot().clear();
getValueSlot().addAll((Collection<? extends Slot>)newValue);
return;
case InstancePackage.INSTANCE__CLASSIFIER:
setClassifier((Classifier)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case InstancePackage.INSTANCE__VALUE_SLOT:
getValueSlot().clear();
return;
case InstancePackage.INSTANCE__CLASSIFIER:
setClassifier((Classifier)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case InstancePackage.INSTANCE__VALUE_SLOT:
return valueSlot != null && !valueSlot.isEmpty();
case InstancePackage.INSTANCE__CLASSIFIER:
return classifier != null;
}
return super.eIsSet(featureID);
}
} //InstanceImpl