/*
 * This file has been developed at the University of Munich, Chair for Programming & Software Engineering.
 * 
 * This file is licensed under the Eclipse Public License (EPL) 1.0
 * 
 */
package eu.mdd4soa.smm.data.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 eu.mdd4soa.smm.data.Declaration;
import eu.mdd4soa.smm.data.ISMDataPackage;
import eu.mdd4soa.smm.data.VariableReference;

/**
 * <!-- begin-user-doc --> An implementation of the model object '
 * <em><b>Declaration</b></em>'. <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 * <li>{@link eu.mdd4soa.smm.data.impl.DeclarationImpl#getDeclaredVar <em>
 * Declared Var</em>}</li>
 * </ul>
 * </p>
 * 
 * @generated
 */
public class DeclarationImpl extends StatementImpl implements Declaration {
	/**
	 * The cached value of the '{@link #getDeclaredVar() <em>Declared Var</em>}'
	 * containment reference. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getDeclaredVar()
	 * @generated
	 * @ordered
	 */
	protected VariableReference declaredVar;

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	protected DeclarationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ISMDataPackage.Literals.DECLARATION;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public VariableReference getDeclaredVar() {
		return declaredVar;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public NotificationChain basicSetDeclaredVar(VariableReference newDeclaredVar, NotificationChain msgs) {
		VariableReference oldDeclaredVar= declaredVar;
		declaredVar= newDeclaredVar;
		if (eNotificationRequired()) {
			ENotificationImpl notification= new ENotificationImpl(this, Notification.SET, ISMDataPackage.DECLARATION__DECLARED_VAR, oldDeclaredVar,
					newDeclaredVar);
			if (msgs == null)
				msgs= notification;
			else
				msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public void setDeclaredVar(VariableReference newDeclaredVar) {
		if (newDeclaredVar != declaredVar) {
			NotificationChain msgs= null;
			if (declaredVar != null)
				msgs= ((InternalEObject) declaredVar).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ISMDataPackage.DECLARATION__DECLARED_VAR, null,
						msgs);
			if (newDeclaredVar != null)
				msgs= ((InternalEObject) newDeclaredVar).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ISMDataPackage.DECLARATION__DECLARED_VAR, null,
						msgs);
			msgs= basicSetDeclaredVar(newDeclaredVar, msgs);
			if (msgs != null)
				msgs.dispatch();
		} else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ISMDataPackage.DECLARATION__DECLARED_VAR, newDeclaredVar, newDeclaredVar));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ISMDataPackage.DECLARATION__DECLARED_VAR:
				return basicSetDeclaredVar(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 ISMDataPackage.DECLARATION__DECLARED_VAR:
				return getDeclaredVar();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ISMDataPackage.DECLARATION__DECLARED_VAR:
				setDeclaredVar((VariableReference) newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ISMDataPackage.DECLARATION__DECLARED_VAR:
				setDeclaredVar((VariableReference) null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ISMDataPackage.DECLARATION__DECLARED_VAR:
				return declaredVar != null;
		}
		return super.eIsSet(featureID);
	}

} // DeclarationImpl
