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

import com.minres.rdl.rdl.Concat;
import com.minres.rdl.rdl.EnumBody;
import com.minres.rdl.rdl.EnumDefinition;
import com.minres.rdl.rdl.InstancePropertyRef;
import com.minres.rdl.rdl.PropertyAssignmentRhs;
import com.minres.rdl.rdl.RValue;
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>Property Assignment Rhs</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link com.minres.rdl.rdl.impl.PropertyAssignmentRhsImpl#getValue <em>Value</em>}</li>
 *   <li>{@link com.minres.rdl.rdl.impl.PropertyAssignmentRhsImpl#getInstPropRef <em>Inst Prop Ref</em>}</li>
 *   <li>{@link com.minres.rdl.rdl.impl.PropertyAssignmentRhsImpl#getEnumRef <em>Enum Ref</em>}</li>
 *   <li>{@link com.minres.rdl.rdl.impl.PropertyAssignmentRhsImpl#getEnums <em>Enums</em>}</li>
 *   <li>{@link com.minres.rdl.rdl.impl.PropertyAssignmentRhsImpl#getElements <em>Elements</em>}</li>
 * </ul>
 *
 * @generated
 */
public class PropertyAssignmentRhsImpl extends MinimalEObjectImpl.Container implements PropertyAssignmentRhs
{
  /**
   * The cached value of the '{@link #getValue() <em>Value</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getValue()
   * @generated
   * @ordered
   */
  protected RValue value;

  /**
   * 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 cached value of the '{@link #getEnumRef() <em>Enum Ref</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEnumRef()
   * @generated
   * @ordered
   */
  protected EnumDefinition enumRef;

  /**
   * The cached value of the '{@link #getEnums() <em>Enums</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEnums()
   * @generated
   * @ordered
   */
  protected EnumBody enums;

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

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

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetValue(RValue newValue, NotificationChain msgs)
  {
    RValue oldValue = value;
    value = newValue;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, RdlPackage.PROPERTY_ASSIGNMENT_RHS__VALUE, oldValue, newValue);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void setValue(RValue newValue)
  {
    if (newValue != value)
    {
      NotificationChain msgs = null;
      if (value != null)
        msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - RdlPackage.PROPERTY_ASSIGNMENT_RHS__VALUE, null, msgs);
      if (newValue != null)
        msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - RdlPackage.PROPERTY_ASSIGNMENT_RHS__VALUE, null, msgs);
      msgs = basicSetValue(newValue, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, RdlPackage.PROPERTY_ASSIGNMENT_RHS__VALUE, newValue, newValue));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  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.PROPERTY_ASSIGNMENT_RHS__INST_PROP_REF, oldInstPropRef, newInstPropRef);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public EnumDefinition getEnumRef()
  {
    if (enumRef != null && enumRef.eIsProxy())
    {
      InternalEObject oldEnumRef = (InternalEObject)enumRef;
      enumRef = (EnumDefinition)eResolveProxy(oldEnumRef);
      if (enumRef != oldEnumRef)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUM_REF, oldEnumRef, enumRef));
      }
    }
    return enumRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EnumDefinition basicGetEnumRef()
  {
    return enumRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void setEnumRef(EnumDefinition newEnumRef)
  {
    EnumDefinition oldEnumRef = enumRef;
    enumRef = newEnumRef;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUM_REF, oldEnumRef, enumRef));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public EnumBody getEnums()
  {
    return enums;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetEnums(EnumBody newEnums, NotificationChain msgs)
  {
    EnumBody oldEnums = enums;
    enums = newEnums;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUMS, oldEnums, newEnums);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void setEnums(EnumBody newEnums)
  {
    if (newEnums != enums)
    {
      NotificationChain msgs = null;
      if (enums != null)
        msgs = ((InternalEObject)enums).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUMS, null, msgs);
      if (newEnums != null)
        msgs = ((InternalEObject)newEnums).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUMS, null, msgs);
      msgs = basicSetEnums(newEnums, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUMS, newEnums, newEnums));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Concat getElements()
  {
    return elements;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetElements(Concat newElements, NotificationChain msgs)
  {
    Concat oldElements = elements;
    elements = newElements;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, RdlPackage.PROPERTY_ASSIGNMENT_RHS__ELEMENTS, oldElements, newElements);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void setElements(Concat newElements)
  {
    if (newElements != elements)
    {
      NotificationChain msgs = null;
      if (elements != null)
        msgs = ((InternalEObject)elements).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - RdlPackage.PROPERTY_ASSIGNMENT_RHS__ELEMENTS, null, msgs);
      if (newElements != null)
        msgs = ((InternalEObject)newElements).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - RdlPackage.PROPERTY_ASSIGNMENT_RHS__ELEMENTS, null, msgs);
      msgs = basicSetElements(newElements, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, RdlPackage.PROPERTY_ASSIGNMENT_RHS__ELEMENTS, newElements, newElements));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__VALUE:
        return basicSetValue(null, msgs);
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__INST_PROP_REF:
        return basicSetInstPropRef(null, msgs);
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUMS:
        return basicSetEnums(null, msgs);
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__ELEMENTS:
        return basicSetElements(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.PROPERTY_ASSIGNMENT_RHS__VALUE:
        return getValue();
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__INST_PROP_REF:
        return getInstPropRef();
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUM_REF:
        if (resolve) return getEnumRef();
        return basicGetEnumRef();
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUMS:
        return getEnums();
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__ELEMENTS:
        return getElements();
    }
    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.PROPERTY_ASSIGNMENT_RHS__VALUE:
        setValue((RValue)newValue);
        return;
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__INST_PROP_REF:
        setInstPropRef((InstancePropertyRef)newValue);
        return;
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUM_REF:
        setEnumRef((EnumDefinition)newValue);
        return;
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUMS:
        setEnums((EnumBody)newValue);
        return;
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__ELEMENTS:
        setElements((Concat)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__VALUE:
        setValue((RValue)null);
        return;
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__INST_PROP_REF:
        setInstPropRef((InstancePropertyRef)null);
        return;
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUM_REF:
        setEnumRef((EnumDefinition)null);
        return;
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUMS:
        setEnums((EnumBody)null);
        return;
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__ELEMENTS:
        setElements((Concat)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__VALUE:
        return value != null;
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__INST_PROP_REF:
        return instPropRef != null;
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUM_REF:
        return enumRef != null;
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__ENUMS:
        return enums != null;
      case RdlPackage.PROPERTY_ASSIGNMENT_RHS__ELEMENTS:
        return elements != null;
    }
    return super.eIsSet(featureID);
  }

} //PropertyAssignmentRhsImpl
