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

import java.lang.reflect.InvocationTargetException;

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.etsi.mts.tdl.Comment;

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

import org.etsi.mts.tdl.structuredobjectives.Element;
import org.etsi.mts.tdl.structuredobjectives.EventOccurrenceSpecification;
import org.etsi.mts.tdl.structuredobjectives.EventSpecificationTemplate;
import org.etsi.mts.tdl.structuredobjectives.StructuredObjectivesPackage;
import org.etsi.mts.tdl.structuredobjectives.StructuredTestObjective;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Event Specification Template</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.etsi.mts.tdl.structuredobjectives.impl.EventSpecificationTemplateImpl#getEventSpecification <em>Event Specification</em>}</li>
 * </ul>
 *
 * @generated
 */
public class EventSpecificationTemplateImpl extends PackageableElementImpl implements EventSpecificationTemplate
{
	/**
	 * The cached value of the '{@link #getEventSpecification() <em>Event Specification</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEventSpecification()
	 * @generated
	 * @ordered
	 */
	protected EventOccurrenceSpecification eventSpecification;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EventOccurrenceSpecification getEventSpecification()
	{
		return eventSpecification;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetEventSpecification(EventOccurrenceSpecification newEventSpecification, NotificationChain msgs)
	{
		EventOccurrenceSpecification oldEventSpecification = eventSpecification;
		eventSpecification = newEventSpecification;
		if (eNotificationRequired())
		{
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.EVENT_SPECIFICATION_TEMPLATE__EVENT_SPECIFICATION, oldEventSpecification, newEventSpecification);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setEventSpecification(EventOccurrenceSpecification newEventSpecification)
	{
		if (newEventSpecification != eventSpecification)
		{
			NotificationChain msgs = null;
			if (eventSpecification != null)
				msgs = ((InternalEObject)eventSpecification).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.EVENT_SPECIFICATION_TEMPLATE__EVENT_SPECIFICATION, null, msgs);
			if (newEventSpecification != null)
				msgs = ((InternalEObject)newEventSpecification).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.EVENT_SPECIFICATION_TEMPLATE__EVENT_SPECIFICATION, null, msgs);
			msgs = basicSetEventSpecification(newEventSpecification, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.EVENT_SPECIFICATION_TEMPLATE__EVENT_SPECIFICATION, newEventSpecification, newEventSpecification));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public StructuredTestObjective getTestObjective()
	{
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean contains(Element object)
	{
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EList<Comment> getNotes()
	{
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.EVENT_SPECIFICATION_TEMPLATE__EVENT_SPECIFICATION:
				return basicSetEventSpecification(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.EVENT_SPECIFICATION_TEMPLATE__EVENT_SPECIFICATION:
				return getEventSpecification();
		}
		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.EVENT_SPECIFICATION_TEMPLATE__EVENT_SPECIFICATION:
				setEventSpecification((EventOccurrenceSpecification)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.EVENT_SPECIFICATION_TEMPLATE__EVENT_SPECIFICATION:
				setEventSpecification((EventOccurrenceSpecification)null);
				return;
		}
		super.eUnset(featureID);
	}

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public int eDerivedOperationID(int baseOperationID, Class<?> baseClass)
	{
		if (baseClass == Element.class)
		{
			switch (baseOperationID)
			{
				case StructuredObjectivesPackage.ELEMENT___GET_TEST_OBJECTIVE: return StructuredObjectivesPackage.EVENT_SPECIFICATION_TEMPLATE___GET_TEST_OBJECTIVE;
				case StructuredObjectivesPackage.ELEMENT___CONTAINS__ELEMENT: return StructuredObjectivesPackage.EVENT_SPECIFICATION_TEMPLATE___CONTAINS__ELEMENT;
				case StructuredObjectivesPackage.ELEMENT___GET_NOTES: return StructuredObjectivesPackage.EVENT_SPECIFICATION_TEMPLATE___GET_NOTES;
				default: return -1;
			}
		}
		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 StructuredObjectivesPackage.EVENT_SPECIFICATION_TEMPLATE___GET_TEST_OBJECTIVE:
				return getTestObjective();
			case StructuredObjectivesPackage.EVENT_SPECIFICATION_TEMPLATE___CONTAINS__ELEMENT:
				return contains((Element)arguments.get(0));
			case StructuredObjectivesPackage.EVENT_SPECIFICATION_TEMPLATE___GET_NOTES:
				return getNotes();
		}
		return super.eInvoke(operationID, arguments);
	}

} //EventSpecificationTemplateImpl
