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

import java.lang.reflect.InvocationTargetException;

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.common.util.WrappedException;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EOperation;
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.AtomicBehaviour;
import org.etsi.mts.tdl.Behaviour;
import org.etsi.mts.tdl.ComponentInstance;
import org.etsi.mts.tdl.TimeConstraint;
import org.etsi.mts.tdl.TimeLabel;
import org.etsi.mts.tdl.tdlPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Atomic Behaviour</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.etsi.mts.tdl.impl.AtomicBehaviourImpl#getTimeConstraint <em>Time Constraint</em>}</li>
 *   <li>{@link org.etsi.mts.tdl.impl.AtomicBehaviourImpl#getTimeLabel <em>Time Label</em>}</li>
 * </ul>
 *
 * @generated
 */
public abstract class AtomicBehaviourImpl extends BehaviourImpl implements AtomicBehaviour
{
	/**
	 * The cached value of the '{@link #getTimeConstraint() <em>Time Constraint</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTimeConstraint()
	 * @generated
	 * @ordered
	 */
	protected EList<TimeConstraint> timeConstraint;

	/**
	 * The cached value of the '{@link #getTimeLabel() <em>Time Label</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTimeLabel()
	 * @generated
	 * @ordered
	 */
	protected TimeLabel timeLabel;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EList<TimeConstraint> getTimeConstraint()
	{
		if (timeConstraint == null)
		{
			timeConstraint = new EObjectContainmentEList<TimeConstraint>(TimeConstraint.class, this, tdlPackage.ATOMIC_BEHAVIOUR__TIME_CONSTRAINT);
		}
		return timeConstraint;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public TimeLabel getTimeLabel()
	{
		return timeLabel;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetTimeLabel(TimeLabel newTimeLabel, NotificationChain msgs)
	{
		TimeLabel oldTimeLabel = timeLabel;
		timeLabel = newTimeLabel;
		if (eNotificationRequired())
		{
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, tdlPackage.ATOMIC_BEHAVIOUR__TIME_LABEL, oldTimeLabel, newTimeLabel);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setTimeLabel(TimeLabel newTimeLabel)
	{
		if (newTimeLabel != timeLabel)
		{
			NotificationChain msgs = null;
			if (timeLabel != null)
				msgs = ((InternalEObject)timeLabel).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - tdlPackage.ATOMIC_BEHAVIOUR__TIME_LABEL, null, msgs);
			if (newTimeLabel != null)
				msgs = ((InternalEObject)newTimeLabel).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - tdlPackage.ATOMIC_BEHAVIOUR__TIME_LABEL, null, msgs);
			msgs = basicSetTimeLabel(newTimeLabel, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, tdlPackage.ATOMIC_BEHAVIOUR__TIME_LABEL, newTimeLabel, newTimeLabel));
	}

	/**
	 * The cached invocation delegate for the '{@link #getParticipatingComponents() <em>Get Participating Components</em>}' operation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getParticipatingComponents()
	 * @generated
	 * @ordered
	 */
	protected static final EOperation.Internal.InvocationDelegate GET_PARTICIPATING_COMPONENTS__EINVOCATION_DELEGATE = ((EOperation.Internal)tdlPackage.Literals.ATOMIC_BEHAVIOUR___GET_PARTICIPATING_COMPONENTS).getInvocationDelegate();

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public EList<ComponentInstance> getParticipatingComponents()
	{
		try
		{
			return (EList<ComponentInstance>)GET_PARTICIPATING_COMPONENTS__EINVOCATION_DELEGATE.dynamicInvoke(this, null);
		}
		catch (InvocationTargetException ite)
		{
			throw new WrappedException(ite);
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
	{
		switch (featureID)
		{
			case tdlPackage.ATOMIC_BEHAVIOUR__TIME_CONSTRAINT:
				return ((InternalEList<?>)getTimeConstraint()).basicRemove(otherEnd, msgs);
			case tdlPackage.ATOMIC_BEHAVIOUR__TIME_LABEL:
				return basicSetTimeLabel(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 tdlPackage.ATOMIC_BEHAVIOUR__TIME_CONSTRAINT:
				return getTimeConstraint();
			case tdlPackage.ATOMIC_BEHAVIOUR__TIME_LABEL:
				return getTimeLabel();
		}
		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.ATOMIC_BEHAVIOUR__TIME_CONSTRAINT:
				getTimeConstraint().clear();
				getTimeConstraint().addAll((Collection<? extends TimeConstraint>)newValue);
				return;
			case tdlPackage.ATOMIC_BEHAVIOUR__TIME_LABEL:
				setTimeLabel((TimeLabel)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID)
	{
		switch (featureID)
		{
			case tdlPackage.ATOMIC_BEHAVIOUR__TIME_CONSTRAINT:
				getTimeConstraint().clear();
				return;
			case tdlPackage.ATOMIC_BEHAVIOUR__TIME_LABEL:
				setTimeLabel((TimeLabel)null);
				return;
		}
		super.eUnset(featureID);
	}

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public int eDerivedOperationID(int baseOperationID, Class<?> baseClass)
	{
		if (baseClass == Behaviour.class)
		{
			switch (baseOperationID)
			{
				case tdlPackage.BEHAVIOUR___GET_PARTICIPATING_COMPONENTS: return tdlPackage.ATOMIC_BEHAVIOUR___GET_PARTICIPATING_COMPONENTS;
				default: return super.eDerivedOperationID(baseOperationID, baseClass);
			}
		}
		return super.eDerivedOperationID(baseOperationID, baseClass);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException
	{
		switch (operationID)
		{
			case tdlPackage.ATOMIC_BEHAVIOUR___GET_PARTICIPATING_COMPONENTS:
				return getParticipatingComponents();
		}
		return super.eInvoke(operationID, arguments);
	}

} //AtomicBehaviourImpl
