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

import com.minres.rdl.rdl.ConcatElem;
import com.minres.rdl.rdl.InstancePropertyRef;
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;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Concat Elem</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link com.minres.rdl.rdl.impl.ConcatElemImpl#getInstPropRef <em>Inst Prop Ref</em>}</li>
 *   <li>{@link com.minres.rdl.rdl.impl.ConcatElemImpl#getValue <em>Value</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ConcatElemImpl extends MinimalEObjectImpl.Container implements ConcatElem
{
  /**
   * The cached value of the '{@link #getInstPropRef() <em>Inst Prop Ref</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getInstPropRef()
   * @generated
   * @ordered
   */
  protected InstancePropertyRef instPropRef;

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

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

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public InstancePropertyRef getInstPropRef()
  {
    return instPropRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetInstPropRef(InstancePropertyRef newInstPropRef, NotificationChain msgs)
  {
    InstancePropertyRef oldInstPropRef = instPropRef;
    instPropRef = newInstPropRef;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, RdlPackage.CONCAT_ELEM__INST_PROP_REF, oldInstPropRef, newInstPropRef);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setInstPropRef(InstancePropertyRef newInstPropRef)
  {
    if (newInstPropRef != instPropRef)
    {
      NotificationChain msgs = null;
      if (instPropRef != null)
        msgs = ((InternalEObject)instPropRef).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - RdlPackage.CONCAT_ELEM__INST_PROP_REF, null, msgs);
      if (newInstPropRef != null)
        msgs = ((InternalEObject)newInstPropRef).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - RdlPackage.CONCAT_ELEM__INST_PROP_REF, null, msgs);
      msgs = basicSetInstPropRef(newInstPropRef, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, RdlPackage.CONCAT_ELEM__INST_PROP_REF, newInstPropRef, newInstPropRef));
  }

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setValue(Object newValue)
  {
    Object oldValue = value;
    value = newValue;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, RdlPackage.CONCAT_ELEM__VALUE, oldValue, value));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case RdlPackage.CONCAT_ELEM__INST_PROP_REF:
        return basicSetInstPropRef(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.CONCAT_ELEM__INST_PROP_REF:
        return getInstPropRef();
      case RdlPackage.CONCAT_ELEM__VALUE:
        return getValue();
    }
    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.CONCAT_ELEM__INST_PROP_REF:
        setInstPropRef((InstancePropertyRef)newValue);
        return;
      case RdlPackage.CONCAT_ELEM__VALUE:
        setValue(newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case RdlPackage.CONCAT_ELEM__INST_PROP_REF:
        setInstPropRef((InstancePropertyRef)null);
        return;
      case RdlPackage.CONCAT_ELEM__VALUE:
        setValue(VALUE_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case RdlPackage.CONCAT_ELEM__INST_PROP_REF:
        return instPropRef != null;
      case RdlPackage.CONCAT_ELEM__VALUE:
        return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value);
    }
    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(" (value: ");
    result.append(value);
    result.append(')');
    return result.toString();
  }

} //ConcatElemImpl
