/**
 * generated by Xtext 2.14.0
 */
package com.minres.rdl.rdl.impl;

import com.minres.rdl.rdl.ComponentInstance;
import com.minres.rdl.rdl.Range;
import com.minres.rdl.rdl.RdlPackage;

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;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Component Instance</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link com.minres.rdl.rdl.impl.ComponentInstanceImpl#getRange <em>Range</em>}</li>
 *   <li>{@link com.minres.rdl.rdl.impl.ComponentInstanceImpl#getReset <em>Reset</em>}</li>
 *   <li>{@link com.minres.rdl.rdl.impl.ComponentInstanceImpl#getAddress <em>Address</em>}</li>
 *   <li>{@link com.minres.rdl.rdl.impl.ComponentInstanceImpl#getAddrInc <em>Addr Inc</em>}</li>
 *   <li>{@link com.minres.rdl.rdl.impl.ComponentInstanceImpl#getAddrMod <em>Addr Mod</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ComponentInstanceImpl extends EntityImpl implements ComponentInstance
{
  /**
   * The cached value of the '{@link #getRange() <em>Range</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRange()
   * @generated
   * @ordered
   */
  protected Range range;

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

  /**
   * The cached value of the '{@link #getReset() <em>Reset</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getReset()
   * @generated
   * @ordered
   */
  protected Object reset = RESET_EDEFAULT;

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

  /**
   * The cached value of the '{@link #getAddress() <em>Address</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAddress()
   * @generated
   * @ordered
   */
  protected Object address = ADDRESS_EDEFAULT;

  /**
   * The default value of the '{@link #getAddrInc() <em>Addr Inc</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAddrInc()
   * @generated
   * @ordered
   */
  protected static final Object ADDR_INC_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getAddrInc() <em>Addr Inc</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAddrInc()
   * @generated
   * @ordered
   */
  protected Object addrInc = ADDR_INC_EDEFAULT;

  /**
   * The default value of the '{@link #getAddrMod() <em>Addr Mod</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAddrMod()
   * @generated
   * @ordered
   */
  protected static final Object ADDR_MOD_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getAddrMod() <em>Addr Mod</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAddrMod()
   * @generated
   * @ordered
   */
  protected Object addrMod = ADDR_MOD_EDEFAULT;

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Range getRange()
  {
    return range;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetRange(Range newRange, NotificationChain msgs)
  {
    Range oldRange = range;
    range = newRange;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, RdlPackage.COMPONENT_INSTANCE__RANGE, oldRange, newRange);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRange(Range newRange)
  {
    if (newRange != range)
    {
      NotificationChain msgs = null;
      if (range != null)
        msgs = ((InternalEObject)range).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - RdlPackage.COMPONENT_INSTANCE__RANGE, null, msgs);
      if (newRange != null)
        msgs = ((InternalEObject)newRange).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - RdlPackage.COMPONENT_INSTANCE__RANGE, null, msgs);
      msgs = basicSetRange(newRange, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, RdlPackage.COMPONENT_INSTANCE__RANGE, newRange, newRange));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Object getReset()
  {
    return reset;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setReset(Object newReset)
  {
    Object oldReset = reset;
    reset = newReset;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, RdlPackage.COMPONENT_INSTANCE__RESET, oldReset, reset));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Object getAddress()
  {
    return address;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAddress(Object newAddress)
  {
    Object oldAddress = address;
    address = newAddress;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, RdlPackage.COMPONENT_INSTANCE__ADDRESS, oldAddress, address));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Object getAddrInc()
  {
    return addrInc;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAddrInc(Object newAddrInc)
  {
    Object oldAddrInc = addrInc;
    addrInc = newAddrInc;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, RdlPackage.COMPONENT_INSTANCE__ADDR_INC, oldAddrInc, addrInc));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Object getAddrMod()
  {
    return addrMod;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAddrMod(Object newAddrMod)
  {
    Object oldAddrMod = addrMod;
    addrMod = newAddrMod;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, RdlPackage.COMPONENT_INSTANCE__ADDR_MOD, oldAddrMod, addrMod));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case RdlPackage.COMPONENT_INSTANCE__RANGE:
        return basicSetRange(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 RdlPackage.COMPONENT_INSTANCE__RANGE:
        return getRange();
      case RdlPackage.COMPONENT_INSTANCE__RESET:
        return getReset();
      case RdlPackage.COMPONENT_INSTANCE__ADDRESS:
        return getAddress();
      case RdlPackage.COMPONENT_INSTANCE__ADDR_INC:
        return getAddrInc();
      case RdlPackage.COMPONENT_INSTANCE__ADDR_MOD:
        return getAddrMod();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case RdlPackage.COMPONENT_INSTANCE__RANGE:
        setRange((Range)newValue);
        return;
      case RdlPackage.COMPONENT_INSTANCE__RESET:
        setReset(newValue);
        return;
      case RdlPackage.COMPONENT_INSTANCE__ADDRESS:
        setAddress(newValue);
        return;
      case RdlPackage.COMPONENT_INSTANCE__ADDR_INC:
        setAddrInc(newValue);
        return;
      case RdlPackage.COMPONENT_INSTANCE__ADDR_MOD:
        setAddrMod(newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case RdlPackage.COMPONENT_INSTANCE__RANGE:
        setRange((Range)null);
        return;
      case RdlPackage.COMPONENT_INSTANCE__RESET:
        setReset(RESET_EDEFAULT);
        return;
      case RdlPackage.COMPONENT_INSTANCE__ADDRESS:
        setAddress(ADDRESS_EDEFAULT);
        return;
      case RdlPackage.COMPONENT_INSTANCE__ADDR_INC:
        setAddrInc(ADDR_INC_EDEFAULT);
        return;
      case RdlPackage.COMPONENT_INSTANCE__ADDR_MOD:
        setAddrMod(ADDR_MOD_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case RdlPackage.COMPONENT_INSTANCE__RANGE:
        return range != null;
      case RdlPackage.COMPONENT_INSTANCE__RESET:
        return RESET_EDEFAULT == null ? reset != null : !RESET_EDEFAULT.equals(reset);
      case RdlPackage.COMPONENT_INSTANCE__ADDRESS:
        return ADDRESS_EDEFAULT == null ? address != null : !ADDRESS_EDEFAULT.equals(address);
      case RdlPackage.COMPONENT_INSTANCE__ADDR_INC:
        return ADDR_INC_EDEFAULT == null ? addrInc != null : !ADDR_INC_EDEFAULT.equals(addrInc);
      case RdlPackage.COMPONENT_INSTANCE__ADDR_MOD:
        return ADDR_MOD_EDEFAULT == null ? addrMod != null : !ADDR_MOD_EDEFAULT.equals(addrMod);
    }
    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(" (reset: ");
    result.append(reset);
    result.append(", address: ");
    result.append(address);
    result.append(", addrInc: ");
    result.append(addrInc);
    result.append(", addrMod: ");
    result.append(addrMod);
    result.append(')');
    return result.toString();
  }

} //ComponentInstanceImpl
