/**
 * generated by Xtext 2.12.0
 */
package gw4e.eclipse.dsl.dSLPolicies.impl;

import gw4e.eclipse.dsl.dSLPolicies.DSLPoliciesPackage;
import gw4e.eclipse.dsl.dSLPolicies.GraphElement;
import gw4e.eclipse.dsl.dSLPolicies.StopCondition;

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>Stop Condition</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link gw4e.eclipse.dsl.dSLPolicies.impl.StopConditionImpl#getPathtype <em>Pathtype</em>}</li>
 *   <li>{@link gw4e.eclipse.dsl.dSLPolicies.impl.StopConditionImpl#getValue <em>Value</em>}</li>
 *   <li>{@link gw4e.eclipse.dsl.dSLPolicies.impl.StopConditionImpl#getPercentage <em>Percentage</em>}</li>
 *   <li>{@link gw4e.eclipse.dsl.dSLPolicies.impl.StopConditionImpl#getGraphelement <em>Graphelement</em>}</li>
 * </ul>
 *
 * @generated
 */
public class StopConditionImpl extends MinimalEObjectImpl.Container implements StopCondition
{
  /**
   * The default value of the '{@link #getPathtype() <em>Pathtype</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPathtype()
   * @generated
   * @ordered
   */
  protected static final String PATHTYPE_EDEFAULT = null;

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

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

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

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

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

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

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

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPathtype(String newPathtype)
  {
    String oldPathtype = pathtype;
    pathtype = newPathtype;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, DSLPoliciesPackage.STOP_CONDITION__PATHTYPE, oldPathtype, pathtype));
  }

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

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPercentage(String newPercentage)
  {
    String oldPercentage = percentage;
    percentage = newPercentage;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, DSLPoliciesPackage.STOP_CONDITION__PERCENTAGE, oldPercentage, percentage));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public GraphElement getGraphelement()
  {
    return graphelement;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetGraphelement(GraphElement newGraphelement, NotificationChain msgs)
  {
    GraphElement oldGraphelement = graphelement;
    graphelement = newGraphelement;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DSLPoliciesPackage.STOP_CONDITION__GRAPHELEMENT, oldGraphelement, newGraphelement);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setGraphelement(GraphElement newGraphelement)
  {
    if (newGraphelement != graphelement)
    {
      NotificationChain msgs = null;
      if (graphelement != null)
        msgs = ((InternalEObject)graphelement).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DSLPoliciesPackage.STOP_CONDITION__GRAPHELEMENT, null, msgs);
      if (newGraphelement != null)
        msgs = ((InternalEObject)newGraphelement).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DSLPoliciesPackage.STOP_CONDITION__GRAPHELEMENT, null, msgs);
      msgs = basicSetGraphelement(newGraphelement, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, DSLPoliciesPackage.STOP_CONDITION__GRAPHELEMENT, newGraphelement, newGraphelement));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case DSLPoliciesPackage.STOP_CONDITION__GRAPHELEMENT:
        return basicSetGraphelement(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 DSLPoliciesPackage.STOP_CONDITION__PATHTYPE:
        return getPathtype();
      case DSLPoliciesPackage.STOP_CONDITION__VALUE:
        return getValue();
      case DSLPoliciesPackage.STOP_CONDITION__PERCENTAGE:
        return getPercentage();
      case DSLPoliciesPackage.STOP_CONDITION__GRAPHELEMENT:
        return getGraphelement();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case DSLPoliciesPackage.STOP_CONDITION__PATHTYPE:
        setPathtype((String)newValue);
        return;
      case DSLPoliciesPackage.STOP_CONDITION__VALUE:
        setValue((Integer)newValue);
        return;
      case DSLPoliciesPackage.STOP_CONDITION__PERCENTAGE:
        setPercentage((String)newValue);
        return;
      case DSLPoliciesPackage.STOP_CONDITION__GRAPHELEMENT:
        setGraphelement((GraphElement)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case DSLPoliciesPackage.STOP_CONDITION__PATHTYPE:
        setPathtype(PATHTYPE_EDEFAULT);
        return;
      case DSLPoliciesPackage.STOP_CONDITION__VALUE:
        setValue(VALUE_EDEFAULT);
        return;
      case DSLPoliciesPackage.STOP_CONDITION__PERCENTAGE:
        setPercentage(PERCENTAGE_EDEFAULT);
        return;
      case DSLPoliciesPackage.STOP_CONDITION__GRAPHELEMENT:
        setGraphelement((GraphElement)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case DSLPoliciesPackage.STOP_CONDITION__PATHTYPE:
        return PATHTYPE_EDEFAULT == null ? pathtype != null : !PATHTYPE_EDEFAULT.equals(pathtype);
      case DSLPoliciesPackage.STOP_CONDITION__VALUE:
        return value != VALUE_EDEFAULT;
      case DSLPoliciesPackage.STOP_CONDITION__PERCENTAGE:
        return PERCENTAGE_EDEFAULT == null ? percentage != null : !PERCENTAGE_EDEFAULT.equals(percentage);
      case DSLPoliciesPackage.STOP_CONDITION__GRAPHELEMENT:
        return graphelement != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuilder result = new StringBuilder(super.toString());
    result.append(" (pathtype: ");
    result.append(pathtype);
    result.append(", value: ");
    result.append(value);
    result.append(", percentage: ");
    result.append(percentage);
    result.append(')');
    return result.toString();
  }

} //StopConditionImpl
