/******************************************************************************* * Copyright (c) 2007, 2010 IBM Corporation, Zeligsoft Inc., and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM - Initial API and implementation * Zeligsoft - Bugs 241426, 207365 *******************************************************************************/ package org.eclipse.ocl.ecore.impl; import java.util.Map; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.util.DiagnosticChain; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.EParameter; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.ocl.ecore.EcorePackage; import org.eclipse.ocl.ecore.VariableExp; import org.eclipse.ocl.expressions.ExpressionsPackage; import org.eclipse.ocl.expressions.Variable; import org.eclipse.ocl.expressions.operations.VariableExpOperations; import org.eclipse.ocl.utilities.Visitor; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Variable Exp</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link org.eclipse.ocl.ecore.impl.VariableExpImpl#getReferredVariable <em>Referred Variable</em>}</li> * </ul> * * @generated */ public class VariableExpImpl extends OCLExpressionImpl implements VariableExp { /** * The cached value of the '{@link #getReferredVariable() <em>Referred Variable</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getReferredVariable() * @generated * @ordered */ protected Variable<EClassifier, EParameter> referredVariable; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected VariableExpImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return EcorePackage.Literals.VARIABLE_EXP; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") public Variable<EClassifier, EParameter> getReferredVariable() { if (referredVariable != null && referredVariable.eIsProxy()) { InternalEObject oldReferredVariable = (InternalEObject) referredVariable; referredVariable = (Variable<EClassifier, EParameter>) eResolveProxy( oldReferredVariable); if (referredVariable != oldReferredVariable) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, EcorePackage.VARIABLE_EXP__REFERRED_VARIABLE, oldReferredVariable, referredVariable)); } } return referredVariable; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Variable<EClassifier, EParameter> basicGetReferredVariable() { return referredVariable; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setReferredVariable( Variable<EClassifier, EParameter> newReferredVariable) { Variable<EClassifier, EParameter> oldReferredVariable = referredVariable; referredVariable = newReferredVariable; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.VARIABLE_EXP__REFERRED_VARIABLE, oldReferredVariable, referredVariable)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public boolean checkVarType(DiagnosticChain diagnostics, Map<Object, Object> context) { return VariableExpOperations.checkVarType(this, diagnostics, context); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case EcorePackage.VARIABLE_EXP__REFERRED_VARIABLE : if (resolve) return getReferredVariable(); return basicGetReferredVariable(); } 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 EcorePackage.VARIABLE_EXP__REFERRED_VARIABLE : setReferredVariable( (Variable<EClassifier, EParameter>) newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case EcorePackage.VARIABLE_EXP__REFERRED_VARIABLE : setReferredVariable((Variable<EClassifier, EParameter>) null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case EcorePackage.VARIABLE_EXP__REFERRED_VARIABLE : return referredVariable != null; } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { if (baseClass == org.eclipse.ocl.expressions.VariableExp.class) { switch (derivedFeatureID) { case EcorePackage.VARIABLE_EXP__REFERRED_VARIABLE : return ExpressionsPackage.VARIABLE_EXP__REFERRED_VARIABLE; default : return -1; } } return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { if (baseClass == org.eclipse.ocl.expressions.VariableExp.class) { switch (baseFeatureID) { case ExpressionsPackage.VARIABLE_EXP__REFERRED_VARIABLE : return EcorePackage.VARIABLE_EXP__REFERRED_VARIABLE; default : return -1; } } return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ @Override public String toString() { return super.toString(); } /** * @generated NOT */ @Override @SuppressWarnings("unchecked") public <T, U extends Visitor<T, ?, ?, ?, ?, ?, ?, ?, ?, ?>> T accept(U v) { return ((Visitor<T, EClassifier, ?, ?, ?, EParameter, ?, ?, ?, ?>) v) .visitVariableExp(this); } } //VariableExpImpl