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

import de.ugoe.cs.swe.bnftools.ebnf.EbnfPackage;
import de.ugoe.cs.swe.bnftools.ebnf.MergeEntry;
import de.ugoe.cs.swe.bnftools.ebnf.MergeRule;
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>Merge Entry</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.MergeEntryImpl#getSectionheader <em>Sectionheader</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.MergeEntryImpl#getMergeRule <em>Merge Rule</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MergeEntryImpl extends MinimalEObjectImpl.Container implements MergeEntry
{
  /**
   * 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 #getMergeRule() <em>Merge Rule</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMergeRule()
   * @generated
   * @ordered
   */
  protected MergeRule mergeRule;

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return EbnfPackage.Literals.MERGE_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.MERGE_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.MERGE_ENTRY__SECTIONHEADER, null, msgs);
      if (newSectionheader != null)
        msgs = ((InternalEObject)newSectionheader).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.MERGE_ENTRY__SECTIONHEADER, null, msgs);
      msgs = basicSetSectionheader(newSectionheader, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.MERGE_ENTRY__SECTIONHEADER, newSectionheader, newSectionheader));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public MergeRule getMergeRule()
  {
    return mergeRule;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetMergeRule(MergeRule newMergeRule, NotificationChain msgs)
  {
    MergeRule oldMergeRule = mergeRule;
    mergeRule = newMergeRule;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EbnfPackage.MERGE_ENTRY__MERGE_RULE, oldMergeRule, newMergeRule);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMergeRule(MergeRule newMergeRule)
  {
    if (newMergeRule != mergeRule)
    {
      NotificationChain msgs = null;
      if (mergeRule != null)
        msgs = ((InternalEObject)mergeRule).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.MERGE_ENTRY__MERGE_RULE, null, msgs);
      if (newMergeRule != null)
        msgs = ((InternalEObject)newMergeRule).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.MERGE_ENTRY__MERGE_RULE, null, msgs);
      msgs = basicSetMergeRule(newMergeRule, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.MERGE_ENTRY__MERGE_RULE, newMergeRule, newMergeRule));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case EbnfPackage.MERGE_ENTRY__SECTIONHEADER:
        return basicSetSectionheader(null, msgs);
      case EbnfPackage.MERGE_ENTRY__MERGE_RULE:
        return basicSetMergeRule(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.MERGE_ENTRY__SECTIONHEADER:
        return getSectionheader();
      case EbnfPackage.MERGE_ENTRY__MERGE_RULE:
        return getMergeRule();
    }
    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.MERGE_ENTRY__SECTIONHEADER:
        setSectionheader((SectionHeading)newValue);
        return;
      case EbnfPackage.MERGE_ENTRY__MERGE_RULE:
        setMergeRule((MergeRule)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

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

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

} //MergeEntryImpl
