/**
 */
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.RuleReference;
import de.ugoe.cs.swe.bnftools.ebnf.StringRule;

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>Atom</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.AtomImpl#getAtomStringRule <em>Atom String Rule</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.AtomImpl#getAtomRuleReference <em>Atom Rule Reference</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AtomImpl extends MinimalEObjectImpl.Container implements Atom
{
  /**
   * The cached value of the '{@link #getAtomStringRule() <em>Atom String Rule</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAtomStringRule()
   * @generated
   * @ordered
   */
  protected StringRule atomStringRule;

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

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public StringRule getAtomStringRule()
  {
    return atomStringRule;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetAtomStringRule(StringRule newAtomStringRule, NotificationChain msgs)
  {
    StringRule oldAtomStringRule = atomStringRule;
    atomStringRule = newAtomStringRule;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EbnfPackage.ATOM__ATOM_STRING_RULE, oldAtomStringRule, newAtomStringRule);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAtomStringRule(StringRule newAtomStringRule)
  {
    if (newAtomStringRule != atomStringRule)
    {
      NotificationChain msgs = null;
      if (atomStringRule != null)
        msgs = ((InternalEObject)atomStringRule).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.ATOM__ATOM_STRING_RULE, null, msgs);
      if (newAtomStringRule != null)
        msgs = ((InternalEObject)newAtomStringRule).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.ATOM__ATOM_STRING_RULE, null, msgs);
      msgs = basicSetAtomStringRule(newAtomStringRule, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.ATOM__ATOM_STRING_RULE, newAtomStringRule, newAtomStringRule));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public RuleReference getAtomRuleReference()
  {
    return atomRuleReference;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetAtomRuleReference(RuleReference newAtomRuleReference, NotificationChain msgs)
  {
    RuleReference oldAtomRuleReference = atomRuleReference;
    atomRuleReference = newAtomRuleReference;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EbnfPackage.ATOM__ATOM_RULE_REFERENCE, oldAtomRuleReference, newAtomRuleReference);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAtomRuleReference(RuleReference newAtomRuleReference)
  {
    if (newAtomRuleReference != atomRuleReference)
    {
      NotificationChain msgs = null;
      if (atomRuleReference != null)
        msgs = ((InternalEObject)atomRuleReference).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.ATOM__ATOM_RULE_REFERENCE, null, msgs);
      if (newAtomRuleReference != null)
        msgs = ((InternalEObject)newAtomRuleReference).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.ATOM__ATOM_RULE_REFERENCE, null, msgs);
      msgs = basicSetAtomRuleReference(newAtomRuleReference, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.ATOM__ATOM_RULE_REFERENCE, newAtomRuleReference, newAtomRuleReference));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case EbnfPackage.ATOM__ATOM_STRING_RULE:
        return basicSetAtomStringRule(null, msgs);
      case EbnfPackage.ATOM__ATOM_RULE_REFERENCE:
        return basicSetAtomRuleReference(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.ATOM__ATOM_STRING_RULE:
        return getAtomStringRule();
      case EbnfPackage.ATOM__ATOM_RULE_REFERENCE:
        return getAtomRuleReference();
    }
    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.ATOM__ATOM_STRING_RULE:
        setAtomStringRule((StringRule)newValue);
        return;
      case EbnfPackage.ATOM__ATOM_RULE_REFERENCE:
        setAtomRuleReference((RuleReference)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case EbnfPackage.ATOM__ATOM_STRING_RULE:
        setAtomStringRule((StringRule)null);
        return;
      case EbnfPackage.ATOM__ATOM_RULE_REFERENCE:
        setAtomRuleReference((RuleReference)null);
        return;
    }
    super.eUnset(featureID);
  }

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

} //AtomImpl
