/**
*/
package IFML.Core.impl;
import IFML.Core.Context;
import IFML.Core.ContextVariable;
import IFML.Core.CorePackage;
import IFML.DataTypes.ContextVariableScope;
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;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Context Variable</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link IFML.Core.impl.ContextVariableImpl#getContext <em>Context</em>}</li>
* <li>{@link IFML.Core.impl.ContextVariableImpl#getScope <em>Scope</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ContextVariableImpl extends NamedElementImpl implements ContextVariable {
/**
* The default value of the '{@link #getScope() <em>Scope</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getScope()
* @generated
* @ordered
*/
protected static final ContextVariableScope SCOPE_EDEFAULT = ContextVariableScope.APPLICATION_SCOPE;
/**
* The cached value of the '{@link #getScope() <em>Scope</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getScope()
* @generated
* @ordered
*/
protected ContextVariableScope scope = SCOPE_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ContextVariableImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CorePackage.Literals.CONTEXT_VARIABLE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Context getContext() {
if (eContainerFeatureID() != CorePackage.CONTEXT_VARIABLE__CONTEXT) return null;
return (Context)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetContext(Context newContext, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newContext, CorePackage.CONTEXT_VARIABLE__CONTEXT, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setContext(Context newContext) {
if (newContext != eInternalContainer() || (eContainerFeatureID() != CorePackage.CONTEXT_VARIABLE__CONTEXT && newContext != null)) {
if (EcoreUtil.isAncestor(this, newContext))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newContext != null)
msgs = ((InternalEObject)newContext).eInverseAdd(this, CorePackage.CONTEXT__CONTEXT_VARIABLES, Context.class, msgs);
msgs = basicSetContext(newContext, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CorePackage.CONTEXT_VARIABLE__CONTEXT, newContext, newContext));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ContextVariableScope getScope() {
return scope;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setScope(ContextVariableScope newScope) {
ContextVariableScope oldScope = scope;
scope = newScope == null ? SCOPE_EDEFAULT : newScope;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CorePackage.CONTEXT_VARIABLE__SCOPE, oldScope, scope));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CorePackage.CONTEXT_VARIABLE__CONTEXT:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetContext((Context)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 CorePackage.CONTEXT_VARIABLE__CONTEXT:
return basicSetContext(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case CorePackage.CONTEXT_VARIABLE__CONTEXT:
return eInternalContainer().eInverseRemove(this, CorePackage.CONTEXT__CONTEXT_VARIABLES, Context.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 CorePackage.CONTEXT_VARIABLE__CONTEXT:
return getContext();
case CorePackage.CONTEXT_VARIABLE__SCOPE:
return getScope();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case CorePackage.CONTEXT_VARIABLE__CONTEXT:
setContext((Context)newValue);
return;
case CorePackage.CONTEXT_VARIABLE__SCOPE:
setScope((ContextVariableScope)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CorePackage.CONTEXT_VARIABLE__CONTEXT:
setContext((Context)null);
return;
case CorePackage.CONTEXT_VARIABLE__SCOPE:
setScope(SCOPE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CorePackage.CONTEXT_VARIABLE__CONTEXT:
return getContext() != null;
case CorePackage.CONTEXT_VARIABLE__SCOPE:
return scope != SCOPE_EDEFAULT;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (scope: ");
result.append(scope);
result.append(')');
return result.toString();
}
} //ContextVariableImpl