/**
 * generated by Xtext version 2.21.0
 */
package ca.queensu.cs.mase.urml.impl;

import ca.queensu.cs.mase.urml.ChooseStatement;
import ca.queensu.cs.mase.urml.Expression;
import ca.queensu.cs.mase.urml.LocalVar;
import ca.queensu.cs.mase.urml.UrmlPackage;

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>Choose Statement</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link ca.queensu.cs.mase.urml.impl.ChooseStatementImpl#getIntVar <em>Int Var</em>}</li>
 *   <li>{@link ca.queensu.cs.mase.urml.impl.ChooseStatementImpl#getIntExp <em>Int Exp</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ChooseStatementImpl extends StatementImpl implements ChooseStatement
{
  /**
   * The cached value of the '{@link #getIntVar() <em>Int Var</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getIntVar()
   * @generated
   * @ordered
   */
  protected LocalVar intVar;

  /**
   * The cached value of the '{@link #getIntExp() <em>Int Exp</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getIntExp()
   * @generated
   * @ordered
   */
  protected Expression intExp;

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public LocalVar getIntVar()
  {
    if (intVar != null && intVar.eIsProxy())
    {
      InternalEObject oldIntVar = (InternalEObject)intVar;
      intVar = (LocalVar)eResolveProxy(oldIntVar);
      if (intVar != oldIntVar)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, UrmlPackage.CHOOSE_STATEMENT__INT_VAR, oldIntVar, intVar));
      }
    }
    return intVar;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public LocalVar basicGetIntVar()
  {
    return intVar;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void setIntVar(LocalVar newIntVar)
  {
    LocalVar oldIntVar = intVar;
    intVar = newIntVar;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UrmlPackage.CHOOSE_STATEMENT__INT_VAR, oldIntVar, intVar));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Expression getIntExp()
  {
    return intExp;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetIntExp(Expression newIntExp, NotificationChain msgs)
  {
    Expression oldIntExp = intExp;
    intExp = newIntExp;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UrmlPackage.CHOOSE_STATEMENT__INT_EXP, oldIntExp, newIntExp);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void setIntExp(Expression newIntExp)
  {
    if (newIntExp != intExp)
    {
      NotificationChain msgs = null;
      if (intExp != null)
        msgs = ((InternalEObject)intExp).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UrmlPackage.CHOOSE_STATEMENT__INT_EXP, null, msgs);
      if (newIntExp != null)
        msgs = ((InternalEObject)newIntExp).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - UrmlPackage.CHOOSE_STATEMENT__INT_EXP, null, msgs);
      msgs = basicSetIntExp(newIntExp, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UrmlPackage.CHOOSE_STATEMENT__INT_EXP, newIntExp, newIntExp));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case UrmlPackage.CHOOSE_STATEMENT__INT_EXP:
        return basicSetIntExp(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 UrmlPackage.CHOOSE_STATEMENT__INT_VAR:
        if (resolve) return getIntVar();
        return basicGetIntVar();
      case UrmlPackage.CHOOSE_STATEMENT__INT_EXP:
        return getIntExp();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case UrmlPackage.CHOOSE_STATEMENT__INT_VAR:
        setIntVar((LocalVar)newValue);
        return;
      case UrmlPackage.CHOOSE_STATEMENT__INT_EXP:
        setIntExp((Expression)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case UrmlPackage.CHOOSE_STATEMENT__INT_VAR:
        setIntVar((LocalVar)null);
        return;
      case UrmlPackage.CHOOSE_STATEMENT__INT_EXP:
        setIntExp((Expression)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case UrmlPackage.CHOOSE_STATEMENT__INT_VAR:
        return intVar != null;
      case UrmlPackage.CHOOSE_STATEMENT__INT_EXP:
        return intExp != null;
    }
    return super.eIsSet(featureID);
  }

} //ChooseStatementImpl
