/**
 */
package org.etsi.mts.tdl.impl;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.etsi.mts.tdl.ComponentInstance;
import org.etsi.mts.tdl.ComponentInstanceBinding;
import org.etsi.mts.tdl.tdlPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Component Instance Binding</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.etsi.mts.tdl.impl.ComponentInstanceBindingImpl#getFormalComponent <em>Formal Component</em>}</li>
 *   <li>{@link org.etsi.mts.tdl.impl.ComponentInstanceBindingImpl#getActualComponent <em>Actual Component</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ComponentInstanceBindingImpl extends ElementImpl implements ComponentInstanceBinding
{
	/**
	 * The cached value of the '{@link #getFormalComponent() <em>Formal Component</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFormalComponent()
	 * @generated
	 * @ordered
	 */
	protected ComponentInstance formalComponent;

	/**
	 * The cached value of the '{@link #getActualComponent() <em>Actual Component</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getActualComponent()
	 * @generated
	 * @ordered
	 */
	protected ComponentInstance actualComponent;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public ComponentInstance getFormalComponent()
	{
		if (formalComponent != null && formalComponent.eIsProxy()) {
			InternalEObject oldFormalComponent = (InternalEObject)formalComponent;
			formalComponent = (ComponentInstance)eResolveProxy(oldFormalComponent);
			if (formalComponent != oldFormalComponent) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, tdlPackage.COMPONENT_INSTANCE_BINDING__FORMAL_COMPONENT, oldFormalComponent, formalComponent));
			}
		}
		return formalComponent;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComponentInstance basicGetFormalComponent()
	{
		return formalComponent;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setFormalComponent(ComponentInstance newFormalComponent)
	{
		ComponentInstance oldFormalComponent = formalComponent;
		formalComponent = newFormalComponent;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, tdlPackage.COMPONENT_INSTANCE_BINDING__FORMAL_COMPONENT, oldFormalComponent, formalComponent));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public ComponentInstance getActualComponent()
	{
		if (actualComponent != null && actualComponent.eIsProxy()) {
			InternalEObject oldActualComponent = (InternalEObject)actualComponent;
			actualComponent = (ComponentInstance)eResolveProxy(oldActualComponent);
			if (actualComponent != oldActualComponent) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, tdlPackage.COMPONENT_INSTANCE_BINDING__ACTUAL_COMPONENT, oldActualComponent, actualComponent));
			}
		}
		return actualComponent;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComponentInstance basicGetActualComponent()
	{
		return actualComponent;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setActualComponent(ComponentInstance newActualComponent)
	{
		ComponentInstance oldActualComponent = actualComponent;
		actualComponent = newActualComponent;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, tdlPackage.COMPONENT_INSTANCE_BINDING__ACTUAL_COMPONENT, oldActualComponent, actualComponent));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType)
	{
		switch (featureID) {
			case tdlPackage.COMPONENT_INSTANCE_BINDING__FORMAL_COMPONENT:
				if (resolve) return getFormalComponent();
				return basicGetFormalComponent();
			case tdlPackage.COMPONENT_INSTANCE_BINDING__ACTUAL_COMPONENT:
				if (resolve) return getActualComponent();
				return basicGetActualComponent();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue)
	{
		switch (featureID) {
			case tdlPackage.COMPONENT_INSTANCE_BINDING__FORMAL_COMPONENT:
				setFormalComponent((ComponentInstance)newValue);
				return;
			case tdlPackage.COMPONENT_INSTANCE_BINDING__ACTUAL_COMPONENT:
				setActualComponent((ComponentInstance)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID)
	{
		switch (featureID) {
			case tdlPackage.COMPONENT_INSTANCE_BINDING__FORMAL_COMPONENT:
				setFormalComponent((ComponentInstance)null);
				return;
			case tdlPackage.COMPONENT_INSTANCE_BINDING__ACTUAL_COMPONENT:
				setActualComponent((ComponentInstance)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID)
	{
		switch (featureID) {
			case tdlPackage.COMPONENT_INSTANCE_BINDING__FORMAL_COMPONENT:
				return formalComponent != null;
			case tdlPackage.COMPONENT_INSTANCE_BINDING__ACTUAL_COMPONENT:
				return actualComponent != null;
		}
		return super.eIsSet(featureID);
	}

} //ComponentInstanceBindingImpl
