/**
*/
package fr.inria.atlanmod.collaboro.history.impl;
import fr.inria.atlanmod.collaboro.history.HistoryPackage;
import fr.inria.atlanmod.collaboro.history.ModelChange;
import fr.inria.atlanmod.collaboro.history.Solution;
import fr.inria.atlanmod.collaboro.history.SyntaxElement;
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.EObjectImpl;
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>Model Change</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link fr.inria.atlanmod.collaboro.history.impl.ModelChangeImpl#getSolution <em>Solution</em>}</li>
* <li>{@link fr.inria.atlanmod.collaboro.history.impl.ModelChangeImpl#getReferredElement <em>Referred Element</em>}</li>
* <li>{@link fr.inria.atlanmod.collaboro.history.impl.ModelChangeImpl#getTarget <em>Target</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public abstract class ModelChangeImpl extends EObjectImpl implements ModelChange {
/**
* The cached value of the '{@link #getReferredElement() <em>Referred Element</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getReferredElement()
* @generated
* @ordered
*/
protected SyntaxElement referredElement;
/**
* The cached value of the '{@link #getTarget() <em>Target</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTarget()
* @generated
* @ordered
*/
protected SyntaxElement target;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ModelChangeImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return HistoryPackage.Literals.MODEL_CHANGE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Solution getSolution() {
if (eContainerFeatureID() != HistoryPackage.MODEL_CHANGE__SOLUTION) return null;
return (Solution)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetSolution(Solution newSolution, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newSolution, HistoryPackage.MODEL_CHANGE__SOLUTION, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSolution(Solution newSolution) {
if (newSolution != eInternalContainer() || (eContainerFeatureID() != HistoryPackage.MODEL_CHANGE__SOLUTION && newSolution != null)) {
if (EcoreUtil.isAncestor(this, newSolution))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newSolution != null)
msgs = ((InternalEObject)newSolution).eInverseAdd(this, HistoryPackage.SOLUTION__CHANGES, Solution.class, msgs);
msgs = basicSetSolution(newSolution, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, HistoryPackage.MODEL_CHANGE__SOLUTION, newSolution, newSolution));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public SyntaxElement getReferredElement() {
return referredElement;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetReferredElement(SyntaxElement newReferredElement, NotificationChain msgs) {
SyntaxElement oldReferredElement = referredElement;
referredElement = newReferredElement;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, HistoryPackage.MODEL_CHANGE__REFERRED_ELEMENT, oldReferredElement, newReferredElement);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setReferredElement(SyntaxElement newReferredElement) {
if (newReferredElement != referredElement) {
NotificationChain msgs = null;
if (referredElement != null)
msgs = ((InternalEObject)referredElement).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - HistoryPackage.MODEL_CHANGE__REFERRED_ELEMENT, null, msgs);
if (newReferredElement != null)
msgs = ((InternalEObject)newReferredElement).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - HistoryPackage.MODEL_CHANGE__REFERRED_ELEMENT, null, msgs);
msgs = basicSetReferredElement(newReferredElement, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, HistoryPackage.MODEL_CHANGE__REFERRED_ELEMENT, newReferredElement, newReferredElement));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public SyntaxElement getTarget() {
return target;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetTarget(SyntaxElement newTarget, NotificationChain msgs) {
SyntaxElement oldTarget = target;
target = newTarget;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, HistoryPackage.MODEL_CHANGE__TARGET, oldTarget, newTarget);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setTarget(SyntaxElement newTarget) {
if (newTarget != target) {
NotificationChain msgs = null;
if (target != null)
msgs = ((InternalEObject)target).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - HistoryPackage.MODEL_CHANGE__TARGET, null, msgs);
if (newTarget != null)
msgs = ((InternalEObject)newTarget).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - HistoryPackage.MODEL_CHANGE__TARGET, null, msgs);
msgs = basicSetTarget(newTarget, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, HistoryPackage.MODEL_CHANGE__TARGET, newTarget, newTarget));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case HistoryPackage.MODEL_CHANGE__SOLUTION:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetSolution((Solution)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 HistoryPackage.MODEL_CHANGE__SOLUTION:
return basicSetSolution(null, msgs);
case HistoryPackage.MODEL_CHANGE__REFERRED_ELEMENT:
return basicSetReferredElement(null, msgs);
case HistoryPackage.MODEL_CHANGE__TARGET:
return basicSetTarget(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case HistoryPackage.MODEL_CHANGE__SOLUTION:
return eInternalContainer().eInverseRemove(this, HistoryPackage.SOLUTION__CHANGES, Solution.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 HistoryPackage.MODEL_CHANGE__SOLUTION:
return getSolution();
case HistoryPackage.MODEL_CHANGE__REFERRED_ELEMENT:
return getReferredElement();
case HistoryPackage.MODEL_CHANGE__TARGET:
return getTarget();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case HistoryPackage.MODEL_CHANGE__SOLUTION:
setSolution((Solution)newValue);
return;
case HistoryPackage.MODEL_CHANGE__REFERRED_ELEMENT:
setReferredElement((SyntaxElement)newValue);
return;
case HistoryPackage.MODEL_CHANGE__TARGET:
setTarget((SyntaxElement)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case HistoryPackage.MODEL_CHANGE__SOLUTION:
setSolution((Solution)null);
return;
case HistoryPackage.MODEL_CHANGE__REFERRED_ELEMENT:
setReferredElement((SyntaxElement)null);
return;
case HistoryPackage.MODEL_CHANGE__TARGET:
setTarget((SyntaxElement)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case HistoryPackage.MODEL_CHANGE__SOLUTION:
return getSolution() != null;
case HistoryPackage.MODEL_CHANGE__REFERRED_ELEMENT:
return referredElement != null;
case HistoryPackage.MODEL_CHANGE__TARGET:
return target != null;
}
return super.eIsSet(featureID);
}
} //ModelChangeImpl