/**
 */
package de.ugoe.cs.swe.bnftools.ebnf.impl;

import de.ugoe.cs.swe.bnftools.ebnf.Atom;
import de.ugoe.cs.swe.bnftools.ebnf.EbnfPackage;
import de.ugoe.cs.swe.bnftools.ebnf.GroupedSequence;
import de.ugoe.cs.swe.bnftools.ebnf.OptionalSequence;
import de.ugoe.cs.swe.bnftools.ebnf.RepeatedSequence;
import de.ugoe.cs.swe.bnftools.ebnf.Term;

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.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Term</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.TermImpl#getTermAtom <em>Term Atom</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.TermImpl#getTermGroupedSequence <em>Term Grouped Sequence</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.TermImpl#getTermOptionalSequence <em>Term Optional Sequence</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.TermImpl#getTermRepeatedSequence <em>Term Repeated Sequence</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TermImpl extends MinimalEObjectImpl.Container implements Term
{
  /**
   * The cached value of the '{@link #getTermAtom() <em>Term Atom</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTermAtom()
   * @generated
   * @ordered
   */
  protected Atom termAtom;

  /**
   * The cached value of the '{@link #getTermGroupedSequence() <em>Term Grouped Sequence</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTermGroupedSequence()
   * @generated
   * @ordered
   */
  protected GroupedSequence termGroupedSequence;

  /**
   * The cached value of the '{@link #getTermOptionalSequence() <em>Term Optional Sequence</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTermOptionalSequence()
   * @generated
   * @ordered
   */
  protected OptionalSequence termOptionalSequence;

  /**
   * The cached value of the '{@link #getTermRepeatedSequence() <em>Term Repeated Sequence</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTermRepeatedSequence()
   * @generated
   * @ordered
   */
  protected RepeatedSequence termRepeatedSequence;

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Atom getTermAtom()
  {
    return termAtom;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetTermAtom(Atom newTermAtom, NotificationChain msgs)
  {
    Atom oldTermAtom = termAtom;
    termAtom = newTermAtom;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EbnfPackage.TERM__TERM_ATOM, oldTermAtom, newTermAtom);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTermAtom(Atom newTermAtom)
  {
    if (newTermAtom != termAtom)
    {
      NotificationChain msgs = null;
      if (termAtom != null)
        msgs = ((InternalEObject)termAtom).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.TERM__TERM_ATOM, null, msgs);
      if (newTermAtom != null)
        msgs = ((InternalEObject)newTermAtom).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.TERM__TERM_ATOM, null, msgs);
      msgs = basicSetTermAtom(newTermAtom, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.TERM__TERM_ATOM, newTermAtom, newTermAtom));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public GroupedSequence getTermGroupedSequence()
  {
    return termGroupedSequence;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetTermGroupedSequence(GroupedSequence newTermGroupedSequence, NotificationChain msgs)
  {
    GroupedSequence oldTermGroupedSequence = termGroupedSequence;
    termGroupedSequence = newTermGroupedSequence;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EbnfPackage.TERM__TERM_GROUPED_SEQUENCE, oldTermGroupedSequence, newTermGroupedSequence);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTermGroupedSequence(GroupedSequence newTermGroupedSequence)
  {
    if (newTermGroupedSequence != termGroupedSequence)
    {
      NotificationChain msgs = null;
      if (termGroupedSequence != null)
        msgs = ((InternalEObject)termGroupedSequence).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.TERM__TERM_GROUPED_SEQUENCE, null, msgs);
      if (newTermGroupedSequence != null)
        msgs = ((InternalEObject)newTermGroupedSequence).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.TERM__TERM_GROUPED_SEQUENCE, null, msgs);
      msgs = basicSetTermGroupedSequence(newTermGroupedSequence, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.TERM__TERM_GROUPED_SEQUENCE, newTermGroupedSequence, newTermGroupedSequence));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public OptionalSequence getTermOptionalSequence()
  {
    return termOptionalSequence;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetTermOptionalSequence(OptionalSequence newTermOptionalSequence, NotificationChain msgs)
  {
    OptionalSequence oldTermOptionalSequence = termOptionalSequence;
    termOptionalSequence = newTermOptionalSequence;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EbnfPackage.TERM__TERM_OPTIONAL_SEQUENCE, oldTermOptionalSequence, newTermOptionalSequence);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTermOptionalSequence(OptionalSequence newTermOptionalSequence)
  {
    if (newTermOptionalSequence != termOptionalSequence)
    {
      NotificationChain msgs = null;
      if (termOptionalSequence != null)
        msgs = ((InternalEObject)termOptionalSequence).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.TERM__TERM_OPTIONAL_SEQUENCE, null, msgs);
      if (newTermOptionalSequence != null)
        msgs = ((InternalEObject)newTermOptionalSequence).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.TERM__TERM_OPTIONAL_SEQUENCE, null, msgs);
      msgs = basicSetTermOptionalSequence(newTermOptionalSequence, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.TERM__TERM_OPTIONAL_SEQUENCE, newTermOptionalSequence, newTermOptionalSequence));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public RepeatedSequence getTermRepeatedSequence()
  {
    return termRepeatedSequence;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetTermRepeatedSequence(RepeatedSequence newTermRepeatedSequence, NotificationChain msgs)
  {
    RepeatedSequence oldTermRepeatedSequence = termRepeatedSequence;
    termRepeatedSequence = newTermRepeatedSequence;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EbnfPackage.TERM__TERM_REPEATED_SEQUENCE, oldTermRepeatedSequence, newTermRepeatedSequence);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTermRepeatedSequence(RepeatedSequence newTermRepeatedSequence)
  {
    if (newTermRepeatedSequence != termRepeatedSequence)
    {
      NotificationChain msgs = null;
      if (termRepeatedSequence != null)
        msgs = ((InternalEObject)termRepeatedSequence).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.TERM__TERM_REPEATED_SEQUENCE, null, msgs);
      if (newTermRepeatedSequence != null)
        msgs = ((InternalEObject)newTermRepeatedSequence).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.TERM__TERM_REPEATED_SEQUENCE, null, msgs);
      msgs = basicSetTermRepeatedSequence(newTermRepeatedSequence, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.TERM__TERM_REPEATED_SEQUENCE, newTermRepeatedSequence, newTermRepeatedSequence));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case EbnfPackage.TERM__TERM_ATOM:
        return basicSetTermAtom(null, msgs);
      case EbnfPackage.TERM__TERM_GROUPED_SEQUENCE:
        return basicSetTermGroupedSequence(null, msgs);
      case EbnfPackage.TERM__TERM_OPTIONAL_SEQUENCE:
        return basicSetTermOptionalSequence(null, msgs);
      case EbnfPackage.TERM__TERM_REPEATED_SEQUENCE:
        return basicSetTermRepeatedSequence(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 EbnfPackage.TERM__TERM_ATOM:
        return getTermAtom();
      case EbnfPackage.TERM__TERM_GROUPED_SEQUENCE:
        return getTermGroupedSequence();
      case EbnfPackage.TERM__TERM_OPTIONAL_SEQUENCE:
        return getTermOptionalSequence();
      case EbnfPackage.TERM__TERM_REPEATED_SEQUENCE:
        return getTermRepeatedSequence();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case EbnfPackage.TERM__TERM_ATOM:
        setTermAtom((Atom)newValue);
        return;
      case EbnfPackage.TERM__TERM_GROUPED_SEQUENCE:
        setTermGroupedSequence((GroupedSequence)newValue);
        return;
      case EbnfPackage.TERM__TERM_OPTIONAL_SEQUENCE:
        setTermOptionalSequence((OptionalSequence)newValue);
        return;
      case EbnfPackage.TERM__TERM_REPEATED_SEQUENCE:
        setTermRepeatedSequence((RepeatedSequence)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case EbnfPackage.TERM__TERM_ATOM:
        setTermAtom((Atom)null);
        return;
      case EbnfPackage.TERM__TERM_GROUPED_SEQUENCE:
        setTermGroupedSequence((GroupedSequence)null);
        return;
      case EbnfPackage.TERM__TERM_OPTIONAL_SEQUENCE:
        setTermOptionalSequence((OptionalSequence)null);
        return;
      case EbnfPackage.TERM__TERM_REPEATED_SEQUENCE:
        setTermRepeatedSequence((RepeatedSequence)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case EbnfPackage.TERM__TERM_ATOM:
        return termAtom != null;
      case EbnfPackage.TERM__TERM_GROUPED_SEQUENCE:
        return termGroupedSequence != null;
      case EbnfPackage.TERM__TERM_OPTIONAL_SEQUENCE:
        return termOptionalSequence != null;
      case EbnfPackage.TERM__TERM_REPEATED_SEQUENCE:
        return termRepeatedSequence != null;
    }
    return super.eIsSet(featureID);
  }

} //TermImpl
