/**
 */
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.ExtRule;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

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;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Ext Rule</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.ExtRuleImpl#getRulenumber <em>Rulenumber</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.ExtRuleImpl#getRulevariant <em>Rulevariant</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.ExtRuleImpl#getName <em>Name</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.ExtRuleImpl#getRuleext <em>Ruleext</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.ExtRuleImpl#getElements <em>Elements</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ExtRuleImpl extends MinimalEObjectImpl.Container implements ExtRule
{
  /**
   * The default value of the '{@link #getRulenumber() <em>Rulenumber</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRulenumber()
   * @generated
   * @ordered
   */
  protected static final int RULENUMBER_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getRulenumber() <em>Rulenumber</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRulenumber()
   * @generated
   * @ordered
   */
  protected int rulenumber = RULENUMBER_EDEFAULT;

  /**
   * The default value of the '{@link #getRulevariant() <em>Rulevariant</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRulevariant()
   * @generated
   * @ordered
   */
  protected static final String RULEVARIANT_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getRulevariant() <em>Rulevariant</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRulevariant()
   * @generated
   * @ordered
   */
  protected String rulevariant = RULEVARIANT_EDEFAULT;

  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The default value of the '{@link #getRuleext() <em>Ruleext</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRuleext()
   * @generated
   * @ordered
   */
  protected static final int RULEEXT_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getRuleext() <em>Ruleext</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRuleext()
   * @generated
   * @ordered
   */
  protected int ruleext = RULEEXT_EDEFAULT;

  /**
   * The cached value of the '{@link #getElements() <em>Elements</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getElements()
   * @generated
   * @ordered
   */
  protected EList<Atom> elements;

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getRulenumber()
  {
    return rulenumber;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRulenumber(int newRulenumber)
  {
    int oldRulenumber = rulenumber;
    rulenumber = newRulenumber;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.EXT_RULE__RULENUMBER, oldRulenumber, rulenumber));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getRulevariant()
  {
    return rulevariant;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRulevariant(String newRulevariant)
  {
    String oldRulevariant = rulevariant;
    rulevariant = newRulevariant;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.EXT_RULE__RULEVARIANT, oldRulevariant, rulevariant));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.EXT_RULE__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getRuleext()
  {
    return ruleext;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRuleext(int newRuleext)
  {
    int oldRuleext = ruleext;
    ruleext = newRuleext;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.EXT_RULE__RULEEXT, oldRuleext, ruleext));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Atom> getElements()
  {
    if (elements == null)
    {
      elements = new EObjectContainmentEList<Atom>(Atom.class, this, EbnfPackage.EXT_RULE__ELEMENTS);
    }
    return elements;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case EbnfPackage.EXT_RULE__ELEMENTS:
        return ((InternalEList<?>)getElements()).basicRemove(otherEnd, 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.EXT_RULE__RULENUMBER:
        return getRulenumber();
      case EbnfPackage.EXT_RULE__RULEVARIANT:
        return getRulevariant();
      case EbnfPackage.EXT_RULE__NAME:
        return getName();
      case EbnfPackage.EXT_RULE__RULEEXT:
        return getRuleext();
      case EbnfPackage.EXT_RULE__ELEMENTS:
        return getElements();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case EbnfPackage.EXT_RULE__RULENUMBER:
        setRulenumber((Integer)newValue);
        return;
      case EbnfPackage.EXT_RULE__RULEVARIANT:
        setRulevariant((String)newValue);
        return;
      case EbnfPackage.EXT_RULE__NAME:
        setName((String)newValue);
        return;
      case EbnfPackage.EXT_RULE__RULEEXT:
        setRuleext((Integer)newValue);
        return;
      case EbnfPackage.EXT_RULE__ELEMENTS:
        getElements().clear();
        getElements().addAll((Collection<? extends Atom>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case EbnfPackage.EXT_RULE__RULENUMBER:
        setRulenumber(RULENUMBER_EDEFAULT);
        return;
      case EbnfPackage.EXT_RULE__RULEVARIANT:
        setRulevariant(RULEVARIANT_EDEFAULT);
        return;
      case EbnfPackage.EXT_RULE__NAME:
        setName(NAME_EDEFAULT);
        return;
      case EbnfPackage.EXT_RULE__RULEEXT:
        setRuleext(RULEEXT_EDEFAULT);
        return;
      case EbnfPackage.EXT_RULE__ELEMENTS:
        getElements().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case EbnfPackage.EXT_RULE__RULENUMBER:
        return rulenumber != RULENUMBER_EDEFAULT;
      case EbnfPackage.EXT_RULE__RULEVARIANT:
        return RULEVARIANT_EDEFAULT == null ? rulevariant != null : !RULEVARIANT_EDEFAULT.equals(rulevariant);
      case EbnfPackage.EXT_RULE__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case EbnfPackage.EXT_RULE__RULEEXT:
        return ruleext != RULEEXT_EDEFAULT;
      case EbnfPackage.EXT_RULE__ELEMENTS:
        return elements != null && !elements.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (rulenumber: ");
    result.append(rulenumber);
    result.append(", rulevariant: ");
    result.append(rulevariant);
    result.append(", name: ");
    result.append(name);
    result.append(", ruleext: ");
    result.append(ruleext);
    result.append(')');
    return result.toString();
  }

} //ExtRuleImpl
