/**
 */
package org.etsi.mts.tdl.extendedconfigurations.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.extendedconfigurations.ComponentReference;
import org.etsi.mts.tdl.extendedconfigurations.ExtendedConfigurationsPackage;
import org.etsi.mts.tdl.extendedconfigurations.TestConfigurationInstance;

import org.etsi.mts.tdl.impl.ElementImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Component Reference</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.etsi.mts.tdl.extendedconfigurations.impl.ComponentReferenceImpl#getComponent <em>Component</em>}</li>
 *   <li>{@link org.etsi.mts.tdl.extendedconfigurations.impl.ComponentReferenceImpl#getConfiguration <em>Configuration</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ComponentReferenceImpl extends ElementImpl implements ComponentReference
{
	/**
	 * The cached value of the '{@link #getComponent() <em>Component</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getComponent()
	 * @generated
	 * @ordered
	 */
	protected ComponentInstance component;

	/**
	 * The cached value of the '{@link #getConfiguration() <em>Configuration</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConfiguration()
	 * @generated
	 * @ordered
	 */
	protected TestConfigurationInstance configuration;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public ComponentInstance getComponent()
	{
		if (component != null && component.eIsProxy())
		{
			InternalEObject oldComponent = (InternalEObject)component;
			component = (ComponentInstance)eResolveProxy(oldComponent);
			if (component != oldComponent)
			{
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ExtendedConfigurationsPackage.COMPONENT_REFERENCE__COMPONENT, oldComponent, component));
			}
		}
		return component;
	}

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setComponent(ComponentInstance newComponent)
	{
		ComponentInstance oldComponent = component;
		component = newComponent;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ExtendedConfigurationsPackage.COMPONENT_REFERENCE__COMPONENT, oldComponent, component));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public TestConfigurationInstance getConfiguration()
	{
		if (configuration != null && configuration.eIsProxy())
		{
			InternalEObject oldConfiguration = (InternalEObject)configuration;
			configuration = (TestConfigurationInstance)eResolveProxy(oldConfiguration);
			if (configuration != oldConfiguration)
			{
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ExtendedConfigurationsPackage.COMPONENT_REFERENCE__CONFIGURATION, oldConfiguration, configuration));
			}
		}
		return configuration;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TestConfigurationInstance basicGetConfiguration()
	{
		return configuration;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setConfiguration(TestConfigurationInstance newConfiguration)
	{
		TestConfigurationInstance oldConfiguration = configuration;
		configuration = newConfiguration;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ExtendedConfigurationsPackage.COMPONENT_REFERENCE__CONFIGURATION, oldConfiguration, configuration));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType)
	{
		switch (featureID)
		{
			case ExtendedConfigurationsPackage.COMPONENT_REFERENCE__COMPONENT:
				if (resolve) return getComponent();
				return basicGetComponent();
			case ExtendedConfigurationsPackage.COMPONENT_REFERENCE__CONFIGURATION:
				if (resolve) return getConfiguration();
				return basicGetConfiguration();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue)
	{
		switch (featureID)
		{
			case ExtendedConfigurationsPackage.COMPONENT_REFERENCE__COMPONENT:
				setComponent((ComponentInstance)newValue);
				return;
			case ExtendedConfigurationsPackage.COMPONENT_REFERENCE__CONFIGURATION:
				setConfiguration((TestConfigurationInstance)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID)
	{
		switch (featureID)
		{
			case ExtendedConfigurationsPackage.COMPONENT_REFERENCE__COMPONENT:
				setComponent((ComponentInstance)null);
				return;
			case ExtendedConfigurationsPackage.COMPONENT_REFERENCE__CONFIGURATION:
				setConfiguration((TestConfigurationInstance)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID)
	{
		switch (featureID)
		{
			case ExtendedConfigurationsPackage.COMPONENT_REFERENCE__COMPONENT:
				return component != null;
			case ExtendedConfigurationsPackage.COMPONENT_REFERENCE__CONFIGURATION:
				return configuration != null;
		}
		return super.eIsSet(featureID);
	}

} //ComponentReferenceImpl
