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

import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry;
import de.ugoe.cs.swe.bnftools.ebnf.EbnfPackage;
import de.ugoe.cs.swe.bnftools.ebnf.Rule;
import de.ugoe.cs.swe.bnftools.ebnf.SectionHeading;

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>Bnf Entry</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.BnfEntryImpl#getSectionheader <em>Sectionheader</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.BnfEntryImpl#getRule <em>Rule</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class BnfEntryImpl extends MinimalEObjectImpl.Container implements BnfEntry
{
  /**
   * The cached value of the '{@link #getSectionheader() <em>Sectionheader</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSectionheader()
   * @generated
   * @ordered
   */
  protected SectionHeading sectionheader;

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

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public SectionHeading getSectionheader()
  {
    return sectionheader;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSectionheader(SectionHeading newSectionheader, NotificationChain msgs)
  {
    SectionHeading oldSectionheader = sectionheader;
    sectionheader = newSectionheader;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EbnfPackage.BNF_ENTRY__SECTIONHEADER, oldSectionheader, newSectionheader);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSectionheader(SectionHeading newSectionheader)
  {
    if (newSectionheader != sectionheader)
    {
      NotificationChain msgs = null;
      if (sectionheader != null)
        msgs = ((InternalEObject)sectionheader).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.BNF_ENTRY__SECTIONHEADER, null, msgs);
      if (newSectionheader != null)
        msgs = ((InternalEObject)newSectionheader).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.BNF_ENTRY__SECTIONHEADER, null, msgs);
      msgs = basicSetSectionheader(newSectionheader, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.BNF_ENTRY__SECTIONHEADER, newSectionheader, newSectionheader));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Rule getRule()
  {
    return rule;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetRule(Rule newRule, NotificationChain msgs)
  {
    Rule oldRule = rule;
    rule = newRule;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EbnfPackage.BNF_ENTRY__RULE, oldRule, newRule);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRule(Rule newRule)
  {
    if (newRule != rule)
    {
      NotificationChain msgs = null;
      if (rule != null)
        msgs = ((InternalEObject)rule).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.BNF_ENTRY__RULE, null, msgs);
      if (newRule != null)
        msgs = ((InternalEObject)newRule).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.BNF_ENTRY__RULE, null, msgs);
      msgs = basicSetRule(newRule, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.BNF_ENTRY__RULE, newRule, newRule));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case EbnfPackage.BNF_ENTRY__SECTIONHEADER:
        return basicSetSectionheader(null, msgs);
      case EbnfPackage.BNF_ENTRY__RULE:
        return basicSetRule(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.BNF_ENTRY__SECTIONHEADER:
        return getSectionheader();
      case EbnfPackage.BNF_ENTRY__RULE:
        return getRule();
    }
    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.BNF_ENTRY__SECTIONHEADER:
        setSectionheader((SectionHeading)newValue);
        return;
      case EbnfPackage.BNF_ENTRY__RULE:
        setRule((Rule)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case EbnfPackage.BNF_ENTRY__SECTIONHEADER:
        setSectionheader((SectionHeading)null);
        return;
      case EbnfPackage.BNF_ENTRY__RULE:
        setRule((Rule)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case EbnfPackage.BNF_ENTRY__SECTIONHEADER:
        return sectionheader != null;
      case EbnfPackage.BNF_ENTRY__RULE:
        return rule != null;
    }
    return super.eIsSet(featureID);
  }

} //BnfEntryImpl
