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

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

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

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

import org.etsi.mts.tdl.structuredobjectives.EventSequence;
import org.etsi.mts.tdl.structuredobjectives.ExpectedBehaviour;
import org.etsi.mts.tdl.structuredobjectives.StructuredObjectivesPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Expected Behaviour</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.etsi.mts.tdl.structuredobjectives.impl.ExpectedBehaviourImpl#getWhenClause <em>When Clause</em>}</li>
 *   <li>{@link org.etsi.mts.tdl.structuredobjectives.impl.ExpectedBehaviourImpl#getThenClause <em>Then Clause</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ExpectedBehaviourImpl extends ElementImpl implements ExpectedBehaviour
{
	/**
	 * The cached value of the '{@link #getWhenClause() <em>When Clause</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getWhenClause()
	 * @generated
	 * @ordered
	 */
	protected EventSequence whenClause;

	/**
	 * The cached value of the '{@link #getThenClause() <em>Then Clause</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getThenClause()
	 * @generated
	 * @ordered
	 */
	protected EventSequence thenClause;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EventSequence getWhenClause()
	{
		return whenClause;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetWhenClause(EventSequence newWhenClause, NotificationChain msgs)
	{
		EventSequence oldWhenClause = whenClause;
		whenClause = newWhenClause;
		if (eNotificationRequired())
		{
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__WHEN_CLAUSE, oldWhenClause, newWhenClause);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setWhenClause(EventSequence newWhenClause)
	{
		if (newWhenClause != whenClause)
		{
			NotificationChain msgs = null;
			if (whenClause != null)
				msgs = ((InternalEObject)whenClause).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__WHEN_CLAUSE, null, msgs);
			if (newWhenClause != null)
				msgs = ((InternalEObject)newWhenClause).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__WHEN_CLAUSE, null, msgs);
			msgs = basicSetWhenClause(newWhenClause, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__WHEN_CLAUSE, newWhenClause, newWhenClause));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EventSequence getThenClause()
	{
		return thenClause;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetThenClause(EventSequence newThenClause, NotificationChain msgs)
	{
		EventSequence oldThenClause = thenClause;
		thenClause = newThenClause;
		if (eNotificationRequired())
		{
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__THEN_CLAUSE, oldThenClause, newThenClause);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setThenClause(EventSequence newThenClause)
	{
		if (newThenClause != thenClause)
		{
			NotificationChain msgs = null;
			if (thenClause != null)
				msgs = ((InternalEObject)thenClause).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__THEN_CLAUSE, null, msgs);
			if (newThenClause != null)
				msgs = ((InternalEObject)newThenClause).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__THEN_CLAUSE, null, msgs);
			msgs = basicSetThenClause(newThenClause, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__THEN_CLAUSE, newThenClause, newThenClause));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__WHEN_CLAUSE:
				return basicSetWhenClause(null, msgs);
			case StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__THEN_CLAUSE:
				return basicSetThenClause(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 StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__WHEN_CLAUSE:
				return getWhenClause();
			case StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__THEN_CLAUSE:
				return getThenClause();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__WHEN_CLAUSE:
				setWhenClause((EventSequence)newValue);
				return;
			case StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__THEN_CLAUSE:
				setThenClause((EventSequence)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__WHEN_CLAUSE:
				setWhenClause((EventSequence)null);
				return;
			case StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__THEN_CLAUSE:
				setThenClause((EventSequence)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__WHEN_CLAUSE:
				return whenClause != null;
			case StructuredObjectivesPackage.EXPECTED_BEHAVIOUR__THEN_CLAUSE:
				return thenClause != null;
		}
		return super.eIsSet(featureID);
	}

} //ExpectedBehaviourImpl
