/**
 */
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.ParameterBinding;
import org.etsi.mts.tdl.ProcedureCall;
import org.etsi.mts.tdl.ProcedureSignature;
import org.etsi.mts.tdl.tdlPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Procedure Call</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.etsi.mts.tdl.impl.ProcedureCallImpl#getSignature <em>Signature</em>}</li>
 *   <li>{@link org.etsi.mts.tdl.impl.ProcedureCallImpl#getArgument <em>Argument</em>}</li>
 *   <li>{@link org.etsi.mts.tdl.impl.ProcedureCallImpl#getReplyTo <em>Reply To</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ProcedureCallImpl extends InteractionImpl implements ProcedureCall
{
	/**
	 * The cached value of the '{@link #getSignature() <em>Signature</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSignature()
	 * @generated
	 * @ordered
	 */
	protected ProcedureSignature signature;

	/**
	 * The cached value of the '{@link #getArgument() <em>Argument</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getArgument()
	 * @generated
	 * @ordered
	 */
	protected EList<ParameterBinding> argument;

	/**
	 * The cached value of the '{@link #getReplyTo() <em>Reply To</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReplyTo()
	 * @generated
	 * @ordered
	 */
	protected ProcedureCall replyTo;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public ProcedureSignature getSignature()
	{
		if (signature != null && signature.eIsProxy())
		{
			InternalEObject oldSignature = (InternalEObject)signature;
			signature = (ProcedureSignature)eResolveProxy(oldSignature);
			if (signature != oldSignature)
			{
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, tdlPackage.PROCEDURE_CALL__SIGNATURE, oldSignature, signature));
			}
		}
		return signature;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ProcedureSignature basicGetSignature()
	{
		return signature;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setSignature(ProcedureSignature newSignature)
	{
		ProcedureSignature oldSignature = signature;
		signature = newSignature;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, tdlPackage.PROCEDURE_CALL__SIGNATURE, oldSignature, signature));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EList<ParameterBinding> getArgument()
	{
		if (argument == null)
		{
			argument = new EObjectContainmentEList<ParameterBinding>(ParameterBinding.class, this, tdlPackage.PROCEDURE_CALL__ARGUMENT);
		}
		return argument;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public ProcedureCall getReplyTo()
	{
		if (replyTo != null && replyTo.eIsProxy())
		{
			InternalEObject oldReplyTo = (InternalEObject)replyTo;
			replyTo = (ProcedureCall)eResolveProxy(oldReplyTo);
			if (replyTo != oldReplyTo)
			{
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, tdlPackage.PROCEDURE_CALL__REPLY_TO, oldReplyTo, replyTo));
			}
		}
		return replyTo;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ProcedureCall basicGetReplyTo()
	{
		return replyTo;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setReplyTo(ProcedureCall newReplyTo)
	{
		ProcedureCall oldReplyTo = replyTo;
		replyTo = newReplyTo;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, tdlPackage.PROCEDURE_CALL__REPLY_TO, oldReplyTo, replyTo));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
	{
		switch (featureID)
		{
			case tdlPackage.PROCEDURE_CALL__ARGUMENT:
				return ((InternalEList<?>)getArgument()).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.PROCEDURE_CALL__SIGNATURE:
				if (resolve) return getSignature();
				return basicGetSignature();
			case tdlPackage.PROCEDURE_CALL__ARGUMENT:
				return getArgument();
			case tdlPackage.PROCEDURE_CALL__REPLY_TO:
				if (resolve) return getReplyTo();
				return basicGetReplyTo();
		}
		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.PROCEDURE_CALL__SIGNATURE:
				setSignature((ProcedureSignature)newValue);
				return;
			case tdlPackage.PROCEDURE_CALL__ARGUMENT:
				getArgument().clear();
				getArgument().addAll((Collection<? extends ParameterBinding>)newValue);
				return;
			case tdlPackage.PROCEDURE_CALL__REPLY_TO:
				setReplyTo((ProcedureCall)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID)
	{
		switch (featureID)
		{
			case tdlPackage.PROCEDURE_CALL__SIGNATURE:
				setSignature((ProcedureSignature)null);
				return;
			case tdlPackage.PROCEDURE_CALL__ARGUMENT:
				getArgument().clear();
				return;
			case tdlPackage.PROCEDURE_CALL__REPLY_TO:
				setReplyTo((ProcedureCall)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID)
	{
		switch (featureID)
		{
			case tdlPackage.PROCEDURE_CALL__SIGNATURE:
				return signature != null;
			case tdlPackage.PROCEDURE_CALL__ARGUMENT:
				return argument != null && !argument.isEmpty();
			case tdlPackage.PROCEDURE_CALL__REPLY_TO:
				return replyTo != null;
		}
		return super.eIsSet(featureID);
	}

} //ProcedureCallImpl
