/**
 */
package org.etsi.mts.tdl.structuredobjectives.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.etsi.mts.tdl.structuredobjectives.StructuredObjectivesPackage;
import org.etsi.mts.tdl.structuredobjectives.Value;
import org.etsi.mts.tdl.structuredobjectives.VariantBinding;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Variant Binding</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.etsi.mts.tdl.structuredobjectives.impl.VariantBindingImpl#getValue <em>Value</em>}</li>
 *   <li>{@link org.etsi.mts.tdl.structuredobjectives.impl.VariantBindingImpl#getBoundTo <em>Bound To</em>}</li>
 * </ul>
 *
 * @generated
 */
public class VariantBindingImpl extends ElementImpl implements VariantBinding
{
	/**
	 * The cached value of the '{@link #getValue() <em>Value</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected Value value;

	/**
	 * The cached value of the '{@link #getBoundTo() <em>Bound To</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBoundTo()
	 * @generated
	 * @ordered
	 */
	protected Value boundTo;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Value getValue()
	{
		return value;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetValue(Value newValue, NotificationChain msgs)
	{
		Value oldValue = value;
		value = newValue;
		if (eNotificationRequired())
		{
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.VARIANT_BINDING__VALUE, oldValue, newValue);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setValue(Value newValue)
	{
		if (newValue != value)
		{
			NotificationChain msgs = null;
			if (value != null)
				msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.VARIANT_BINDING__VALUE, null, msgs);
			if (newValue != null)
				msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.VARIANT_BINDING__VALUE, null, msgs);
			msgs = basicSetValue(newValue, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.VARIANT_BINDING__VALUE, newValue, newValue));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Value getBoundTo()
	{
		return boundTo;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetBoundTo(Value newBoundTo, NotificationChain msgs)
	{
		Value oldBoundTo = boundTo;
		boundTo = newBoundTo;
		if (eNotificationRequired())
		{
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.VARIANT_BINDING__BOUND_TO, oldBoundTo, newBoundTo);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setBoundTo(Value newBoundTo)
	{
		if (newBoundTo != boundTo)
		{
			NotificationChain msgs = null;
			if (boundTo != null)
				msgs = ((InternalEObject)boundTo).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.VARIANT_BINDING__BOUND_TO, null, msgs);
			if (newBoundTo != null)
				msgs = ((InternalEObject)newBoundTo).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.VARIANT_BINDING__BOUND_TO, null, msgs);
			msgs = basicSetBoundTo(newBoundTo, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.VARIANT_BINDING__BOUND_TO, newBoundTo, newBoundTo));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.VARIANT_BINDING__VALUE:
				return basicSetValue(null, msgs);
			case StructuredObjectivesPackage.VARIANT_BINDING__BOUND_TO:
				return basicSetBoundTo(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 StructuredObjectivesPackage.VARIANT_BINDING__VALUE:
				return getValue();
			case StructuredObjectivesPackage.VARIANT_BINDING__BOUND_TO:
				return getBoundTo();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.VARIANT_BINDING__VALUE:
				setValue((Value)newValue);
				return;
			case StructuredObjectivesPackage.VARIANT_BINDING__BOUND_TO:
				setBoundTo((Value)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.VARIANT_BINDING__VALUE:
				setValue((Value)null);
				return;
			case StructuredObjectivesPackage.VARIANT_BINDING__BOUND_TO:
				setBoundTo((Value)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.VARIANT_BINDING__VALUE:
				return value != null;
			case StructuredObjectivesPackage.VARIANT_BINDING__BOUND_TO:
				return boundTo != null;
		}
		return super.eIsSet(featureID);
	}

} //VariantBindingImpl
