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

import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry;
import de.ugoe.cs.swe.bnftools.ebnf.DeltaEntry;
import de.ugoe.cs.swe.bnftools.ebnf.EbnfPackage;
import de.ugoe.cs.swe.bnftools.ebnf.EtsiBnf;
import de.ugoe.cs.swe.bnftools.ebnf.ImportSection;
import de.ugoe.cs.swe.bnftools.ebnf.MergeEntry;

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>Etsi Bnf</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.EtsiBnfImpl#getName <em>Name</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.EtsiBnfImpl#getType <em>Type</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.EtsiBnfImpl#getImportSection <em>Import Section</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.EtsiBnfImpl#getBnfEntry <em>Bnf Entry</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.EtsiBnfImpl#getDeltaEntry <em>Delta Entry</em>}</li>
 *   <li>{@link de.ugoe.cs.swe.bnftools.ebnf.impl.EtsiBnfImpl#getMergeEntry <em>Merge Entry</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class EtsiBnfImpl extends MinimalEObjectImpl.Container implements EtsiBnf
{
  /**
   * 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 #getType() <em>Type</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getType()
   * @generated
   * @ordered
   */
  protected static final String TYPE_EDEFAULT = null;

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

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

  /**
   * The cached value of the '{@link #getBnfEntry() <em>Bnf Entry</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getBnfEntry()
   * @generated
   * @ordered
   */
  protected EList<BnfEntry> bnfEntry;

  /**
   * The cached value of the '{@link #getDeltaEntry() <em>Delta Entry</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDeltaEntry()
   * @generated
   * @ordered
   */
  protected EList<DeltaEntry> deltaEntry;

  /**
   * The cached value of the '{@link #getMergeEntry() <em>Merge Entry</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMergeEntry()
   * @generated
   * @ordered
   */
  protected EList<MergeEntry> mergeEntry;

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

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

  /**
   * <!-- 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.ETSI_BNF__NAME, oldName, name));
  }

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setType(String newType)
  {
    String oldType = type;
    type = newType;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.ETSI_BNF__TYPE, oldType, type));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ImportSection getImportSection()
  {
    return importSection;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetImportSection(ImportSection newImportSection, NotificationChain msgs)
  {
    ImportSection oldImportSection = importSection;
    importSection = newImportSection;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EbnfPackage.ETSI_BNF__IMPORT_SECTION, oldImportSection, newImportSection);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setImportSection(ImportSection newImportSection)
  {
    if (newImportSection != importSection)
    {
      NotificationChain msgs = null;
      if (importSection != null)
        msgs = ((InternalEObject)importSection).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.ETSI_BNF__IMPORT_SECTION, null, msgs);
      if (newImportSection != null)
        msgs = ((InternalEObject)newImportSection).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EbnfPackage.ETSI_BNF__IMPORT_SECTION, null, msgs);
      msgs = basicSetImportSection(newImportSection, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EbnfPackage.ETSI_BNF__IMPORT_SECTION, newImportSection, newImportSection));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<BnfEntry> getBnfEntry()
  {
    if (bnfEntry == null)
    {
      bnfEntry = new EObjectContainmentEList<BnfEntry>(BnfEntry.class, this, EbnfPackage.ETSI_BNF__BNF_ENTRY);
    }
    return bnfEntry;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<DeltaEntry> getDeltaEntry()
  {
    if (deltaEntry == null)
    {
      deltaEntry = new EObjectContainmentEList<DeltaEntry>(DeltaEntry.class, this, EbnfPackage.ETSI_BNF__DELTA_ENTRY);
    }
    return deltaEntry;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<MergeEntry> getMergeEntry()
  {
    if (mergeEntry == null)
    {
      mergeEntry = new EObjectContainmentEList<MergeEntry>(MergeEntry.class, this, EbnfPackage.ETSI_BNF__MERGE_ENTRY);
    }
    return mergeEntry;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case EbnfPackage.ETSI_BNF__IMPORT_SECTION:
        return basicSetImportSection(null, msgs);
      case EbnfPackage.ETSI_BNF__BNF_ENTRY:
        return ((InternalEList<?>)getBnfEntry()).basicRemove(otherEnd, msgs);
      case EbnfPackage.ETSI_BNF__DELTA_ENTRY:
        return ((InternalEList<?>)getDeltaEntry()).basicRemove(otherEnd, msgs);
      case EbnfPackage.ETSI_BNF__MERGE_ENTRY:
        return ((InternalEList<?>)getMergeEntry()).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.ETSI_BNF__NAME:
        return getName();
      case EbnfPackage.ETSI_BNF__TYPE:
        return getType();
      case EbnfPackage.ETSI_BNF__IMPORT_SECTION:
        return getImportSection();
      case EbnfPackage.ETSI_BNF__BNF_ENTRY:
        return getBnfEntry();
      case EbnfPackage.ETSI_BNF__DELTA_ENTRY:
        return getDeltaEntry();
      case EbnfPackage.ETSI_BNF__MERGE_ENTRY:
        return getMergeEntry();
    }
    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.ETSI_BNF__NAME:
        setName((String)newValue);
        return;
      case EbnfPackage.ETSI_BNF__TYPE:
        setType((String)newValue);
        return;
      case EbnfPackage.ETSI_BNF__IMPORT_SECTION:
        setImportSection((ImportSection)newValue);
        return;
      case EbnfPackage.ETSI_BNF__BNF_ENTRY:
        getBnfEntry().clear();
        getBnfEntry().addAll((Collection<? extends BnfEntry>)newValue);
        return;
      case EbnfPackage.ETSI_BNF__DELTA_ENTRY:
        getDeltaEntry().clear();
        getDeltaEntry().addAll((Collection<? extends DeltaEntry>)newValue);
        return;
      case EbnfPackage.ETSI_BNF__MERGE_ENTRY:
        getMergeEntry().clear();
        getMergeEntry().addAll((Collection<? extends MergeEntry>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case EbnfPackage.ETSI_BNF__NAME:
        setName(NAME_EDEFAULT);
        return;
      case EbnfPackage.ETSI_BNF__TYPE:
        setType(TYPE_EDEFAULT);
        return;
      case EbnfPackage.ETSI_BNF__IMPORT_SECTION:
        setImportSection((ImportSection)null);
        return;
      case EbnfPackage.ETSI_BNF__BNF_ENTRY:
        getBnfEntry().clear();
        return;
      case EbnfPackage.ETSI_BNF__DELTA_ENTRY:
        getDeltaEntry().clear();
        return;
      case EbnfPackage.ETSI_BNF__MERGE_ENTRY:
        getMergeEntry().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case EbnfPackage.ETSI_BNF__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case EbnfPackage.ETSI_BNF__TYPE:
        return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
      case EbnfPackage.ETSI_BNF__IMPORT_SECTION:
        return importSection != null;
      case EbnfPackage.ETSI_BNF__BNF_ENTRY:
        return bnfEntry != null && !bnfEntry.isEmpty();
      case EbnfPackage.ETSI_BNF__DELTA_ENTRY:
        return deltaEntry != null && !deltaEntry.isEmpty();
      case EbnfPackage.ETSI_BNF__MERGE_ENTRY:
        return mergeEntry != null && !mergeEntry.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(" (name: ");
    result.append(name);
    result.append(", type: ");
    result.append(type);
    result.append(')');
    return result.toString();
  }

} //EtsiBnfImpl
