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

import java.util.Collection;

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

import org.eclipse.emf.common.util.EList;

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

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

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.etsi.mts.tdl.GateReference;
import org.etsi.mts.tdl.Target;
import org.etsi.mts.tdl.ValueAssignment;
import org.etsi.mts.tdl.tdlPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Target</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.etsi.mts.tdl.impl.TargetImpl#getTargetGate <em>Target Gate</em>}</li>
 *   <li>{@link org.etsi.mts.tdl.impl.TargetImpl#getValueAssignment <em>Value Assignment</em>}</li>
 * </ul>
 *
 * @generated
 */
public class TargetImpl extends ElementImpl implements Target
{
	/**
	 * The cached value of the '{@link #getTargetGate() <em>Target Gate</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTargetGate()
	 * @generated
	 * @ordered
	 */
	protected GateReference targetGate;

	/**
	 * The cached value of the '{@link #getValueAssignment() <em>Value Assignment</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValueAssignment()
	 * @generated
	 * @ordered
	 */
	protected EList<ValueAssignment> valueAssignment;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public GateReference getTargetGate()
	{
		if (targetGate != null && targetGate.eIsProxy())
		{
			InternalEObject oldTargetGate = (InternalEObject)targetGate;
			targetGate = (GateReference)eResolveProxy(oldTargetGate);
			if (targetGate != oldTargetGate)
			{
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, tdlPackage.TARGET__TARGET_GATE, oldTargetGate, targetGate));
			}
		}
		return targetGate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public GateReference basicGetTargetGate()
	{
		return targetGate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setTargetGate(GateReference newTargetGate)
	{
		GateReference oldTargetGate = targetGate;
		targetGate = newTargetGate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, tdlPackage.TARGET__TARGET_GATE, oldTargetGate, targetGate));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EList<ValueAssignment> getValueAssignment()
	{
		if (valueAssignment == null)
		{
			valueAssignment = new EObjectContainmentEList<ValueAssignment>(ValueAssignment.class, this, tdlPackage.TARGET__VALUE_ASSIGNMENT);
		}
		return valueAssignment;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
	{
		switch (featureID)
		{
			case tdlPackage.TARGET__VALUE_ASSIGNMENT:
				return ((InternalEList<?>)getValueAssignment()).basicRemove(otherEnd, 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 tdlPackage.TARGET__TARGET_GATE:
				if (resolve) return getTargetGate();
				return basicGetTargetGate();
			case tdlPackage.TARGET__VALUE_ASSIGNMENT:
				return getValueAssignment();
		}
		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 tdlPackage.TARGET__TARGET_GATE:
				setTargetGate((GateReference)newValue);
				return;
			case tdlPackage.TARGET__VALUE_ASSIGNMENT:
				getValueAssignment().clear();
				getValueAssignment().addAll((Collection<? extends ValueAssignment>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID)
	{
		switch (featureID)
		{
			case tdlPackage.TARGET__TARGET_GATE:
				setTargetGate((GateReference)null);
				return;
			case tdlPackage.TARGET__VALUE_ASSIGNMENT:
				getValueAssignment().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID)
	{
		switch (featureID)
		{
			case tdlPackage.TARGET__TARGET_GATE:
				return targetGate != null;
			case tdlPackage.TARGET__VALUE_ASSIGNMENT:
				return valueAssignment != null && !valueAssignment.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //TargetImpl
