/**
 */
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.RepeatedEventSequence;
import org.etsi.mts.tdl.structuredobjectives.StructuredObjectivesPackage;
import org.etsi.mts.tdl.structuredobjectives.Value;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Repeated Event Sequence</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.etsi.mts.tdl.structuredobjectives.impl.RepeatedEventSequenceImpl#getRepetitions <em>Repetitions</em>}</li>
 *   <li>{@link org.etsi.mts.tdl.structuredobjectives.impl.RepeatedEventSequenceImpl#getInterval <em>Interval</em>}</li>
 * </ul>
 *
 * @generated
 */
public class RepeatedEventSequenceImpl extends EventSequenceImpl implements RepeatedEventSequence
{
	/**
	 * The cached value of the '{@link #getRepetitions() <em>Repetitions</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRepetitions()
	 * @generated
	 * @ordered
	 */
	protected Value repetitions;

	/**
	 * The cached value of the '{@link #getInterval() <em>Interval</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInterval()
	 * @generated
	 * @ordered
	 */
	protected Value interval;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Value getRepetitions()
	{
		return repetitions;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetRepetitions(Value newRepetitions, NotificationChain msgs)
	{
		Value oldRepetitions = repetitions;
		repetitions = newRepetitions;
		if (eNotificationRequired())
		{
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.REPEATED_EVENT_SEQUENCE__REPETITIONS, oldRepetitions, newRepetitions);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setRepetitions(Value newRepetitions)
	{
		if (newRepetitions != repetitions)
		{
			NotificationChain msgs = null;
			if (repetitions != null)
				msgs = ((InternalEObject)repetitions).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.REPEATED_EVENT_SEQUENCE__REPETITIONS, null, msgs);
			if (newRepetitions != null)
				msgs = ((InternalEObject)newRepetitions).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.REPEATED_EVENT_SEQUENCE__REPETITIONS, null, msgs);
			msgs = basicSetRepetitions(newRepetitions, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.REPEATED_EVENT_SEQUENCE__REPETITIONS, newRepetitions, newRepetitions));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Value getInterval()
	{
		return interval;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetInterval(Value newInterval, NotificationChain msgs)
	{
		Value oldInterval = interval;
		interval = newInterval;
		if (eNotificationRequired())
		{
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.REPEATED_EVENT_SEQUENCE__INTERVAL, oldInterval, newInterval);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setInterval(Value newInterval)
	{
		if (newInterval != interval)
		{
			NotificationChain msgs = null;
			if (interval != null)
				msgs = ((InternalEObject)interval).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.REPEATED_EVENT_SEQUENCE__INTERVAL, null, msgs);
			if (newInterval != null)
				msgs = ((InternalEObject)newInterval).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.REPEATED_EVENT_SEQUENCE__INTERVAL, null, msgs);
			msgs = basicSetInterval(newInterval, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.REPEATED_EVENT_SEQUENCE__INTERVAL, newInterval, newInterval));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.REPEATED_EVENT_SEQUENCE__REPETITIONS:
				return basicSetRepetitions(null, msgs);
			case StructuredObjectivesPackage.REPEATED_EVENT_SEQUENCE__INTERVAL:
				return basicSetInterval(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.REPEATED_EVENT_SEQUENCE__REPETITIONS:
				return getRepetitions();
			case StructuredObjectivesPackage.REPEATED_EVENT_SEQUENCE__INTERVAL:
				return getInterval();
		}
		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.REPEATED_EVENT_SEQUENCE__REPETITIONS:
				setRepetitions((Value)newValue);
				return;
			case StructuredObjectivesPackage.REPEATED_EVENT_SEQUENCE__INTERVAL:
				setInterval((Value)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.REPEATED_EVENT_SEQUENCE__REPETITIONS:
				setRepetitions((Value)null);
				return;
			case StructuredObjectivesPackage.REPEATED_EVENT_SEQUENCE__INTERVAL:
				setInterval((Value)null);
				return;
		}
		super.eUnset(featureID);
	}

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

} //RepeatedEventSequenceImpl
