/**
* <copyright>
* </copyright>
*
* $Id$
*/
package orgomg.cwm.objectmodel.behavioral.impl;
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.util.EcoreUtil;
import orgomg.cwm.objectmodel.behavioral.Argument;
import orgomg.cwm.objectmodel.behavioral.BehavioralPackage;
import orgomg.cwm.objectmodel.behavioral.CallAction;
import orgomg.cwm.objectmodel.core.Expression;
import orgomg.cwm.objectmodel.core.impl.ModelElementImpl;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Argument</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link orgomg.cwm.objectmodel.behavioral.impl.ArgumentImpl#getValue <em>Value</em>}</li>
* <li>{@link orgomg.cwm.objectmodel.behavioral.impl.ArgumentImpl#getCallAction <em>Call Action</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ArgumentImpl extends ModelElementImpl implements Argument {
/**
* The cached value of the '{@link #getValue() <em>Value</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getValue()
* @generated
* @ordered
*/
protected Expression value;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ArgumentImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return BehavioralPackage.Literals.ARGUMENT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Expression getValue() {
return value;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetValue(Expression newValue, NotificationChain msgs) {
Expression oldValue = value;
value = newValue;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, BehavioralPackage.ARGUMENT__VALUE, oldValue, newValue);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setValue(Expression newValue) {
if (newValue != value) {
NotificationChain msgs = null;
if (value != null)
msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - BehavioralPackage.ARGUMENT__VALUE, null, msgs);
if (newValue != null)
msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - BehavioralPackage.ARGUMENT__VALUE, null, msgs);
msgs = basicSetValue(newValue, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, BehavioralPackage.ARGUMENT__VALUE, newValue, newValue));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public CallAction getCallAction() {
if (eContainerFeatureID() != BehavioralPackage.ARGUMENT__CALL_ACTION) return null;
return (CallAction)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetCallAction(CallAction newCallAction, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newCallAction, BehavioralPackage.ARGUMENT__CALL_ACTION, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setCallAction(CallAction newCallAction) {
if (newCallAction != eInternalContainer() || (eContainerFeatureID() != BehavioralPackage.ARGUMENT__CALL_ACTION && newCallAction != null)) {
if (EcoreUtil.isAncestor(this, newCallAction))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newCallAction != null)
msgs = ((InternalEObject)newCallAction).eInverseAdd(this, BehavioralPackage.CALL_ACTION__ACTUAL_ARGUMENT, CallAction.class, msgs);
msgs = basicSetCallAction(newCallAction, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, BehavioralPackage.ARGUMENT__CALL_ACTION, newCallAction, newCallAction));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case BehavioralPackage.ARGUMENT__CALL_ACTION:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetCallAction((CallAction)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 BehavioralPackage.ARGUMENT__VALUE:
return basicSetValue(null, msgs);
case BehavioralPackage.ARGUMENT__CALL_ACTION:
return basicSetCallAction(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case BehavioralPackage.ARGUMENT__CALL_ACTION:
return eInternalContainer().eInverseRemove(this, BehavioralPackage.CALL_ACTION__ACTUAL_ARGUMENT, CallAction.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 BehavioralPackage.ARGUMENT__VALUE:
return getValue();
case BehavioralPackage.ARGUMENT__CALL_ACTION:
return getCallAction();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case BehavioralPackage.ARGUMENT__VALUE:
setValue((Expression)newValue);
return;
case BehavioralPackage.ARGUMENT__CALL_ACTION:
setCallAction((CallAction)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case BehavioralPackage.ARGUMENT__VALUE:
setValue((Expression)null);
return;
case BehavioralPackage.ARGUMENT__CALL_ACTION:
setCallAction((CallAction)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case BehavioralPackage.ARGUMENT__VALUE:
return value != null;
case BehavioralPackage.ARGUMENT__CALL_ACTION:
return getCallAction() != null;
}
return super.eIsSet(featureID);
}
} //ArgumentImpl