/**
 * generated by Xtext 2.26.0
 */
package org.xtext.example.mydsl.myDsl.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

import org.xtext.example.mydsl.myDsl.CompoundTask;
import org.xtext.example.mydsl.myDsl.Location;
import org.xtext.example.mydsl.myDsl.MyDslPackage;
import org.xtext.example.mydsl.myDsl.TasksModel;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Compound Task</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.CompoundTaskImpl#getCanDoTask <em>Can Do Task</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.CompoundTaskImpl#getLocation <em>Location</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.CompoundTaskImpl#isOrdered <em>Ordered</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.CompoundTaskImpl#isConsecutive <em>Consecutive</em>}</li>
 * </ul>
 *
 * @generated
 */
public class CompoundTaskImpl extends TasksModelImpl implements CompoundTask
{
  /**
   * The cached value of the '{@link #getCanDoTask() <em>Can Do Task</em>}' reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCanDoTask()
   * @generated
   * @ordered
   */
  protected EList<TasksModel> canDoTask;

  /**
   * The cached value of the '{@link #getLocation() <em>Location</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLocation()
   * @generated
   * @ordered
   */
  protected Location location;

  /**
   * The default value of the '{@link #isOrdered() <em>Ordered</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isOrdered()
   * @generated
   * @ordered
   */
  protected static final boolean ORDERED_EDEFAULT = false;

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

  /**
   * The default value of the '{@link #isConsecutive() <em>Consecutive</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isConsecutive()
   * @generated
   * @ordered
   */
  protected static final boolean CONSECUTIVE_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isConsecutive() <em>Consecutive</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isConsecutive()
   * @generated
   * @ordered
   */
  protected boolean consecutive = CONSECUTIVE_EDEFAULT;

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public EList<TasksModel> getCanDoTask()
  {
    if (canDoTask == null)
    {
      canDoTask = new EObjectResolvingEList<TasksModel>(TasksModel.class, this, MyDslPackage.COMPOUND_TASK__CAN_DO_TASK);
    }
    return canDoTask;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Location getLocation()
  {
    if (location != null && location.eIsProxy())
    {
      InternalEObject oldLocation = (InternalEObject)location;
      location = (Location)eResolveProxy(oldLocation);
      if (location != oldLocation)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, MyDslPackage.COMPOUND_TASK__LOCATION, oldLocation, location));
      }
    }
    return location;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Location basicGetLocation()
  {
    return location;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void setLocation(Location newLocation)
  {
    Location oldLocation = location;
    location = newLocation;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.COMPOUND_TASK__LOCATION, oldLocation, location));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean isOrdered()
  {
    return ordered;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void setOrdered(boolean newOrdered)
  {
    boolean oldOrdered = ordered;
    ordered = newOrdered;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.COMPOUND_TASK__ORDERED, oldOrdered, ordered));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean isConsecutive()
  {
    return consecutive;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void setConsecutive(boolean newConsecutive)
  {
    boolean oldConsecutive = consecutive;
    consecutive = newConsecutive;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.COMPOUND_TASK__CONSECUTIVE, oldConsecutive, consecutive));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case MyDslPackage.COMPOUND_TASK__CAN_DO_TASK:
        return getCanDoTask();
      case MyDslPackage.COMPOUND_TASK__LOCATION:
        if (resolve) return getLocation();
        return basicGetLocation();
      case MyDslPackage.COMPOUND_TASK__ORDERED:
        return isOrdered();
      case MyDslPackage.COMPOUND_TASK__CONSECUTIVE:
        return isConsecutive();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MyDslPackage.COMPOUND_TASK__CAN_DO_TASK:
        getCanDoTask().clear();
        getCanDoTask().addAll((Collection<? extends TasksModel>)newValue);
        return;
      case MyDslPackage.COMPOUND_TASK__LOCATION:
        setLocation((Location)newValue);
        return;
      case MyDslPackage.COMPOUND_TASK__ORDERED:
        setOrdered((Boolean)newValue);
        return;
      case MyDslPackage.COMPOUND_TASK__CONSECUTIVE:
        setConsecutive((Boolean)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MyDslPackage.COMPOUND_TASK__CAN_DO_TASK:
        getCanDoTask().clear();
        return;
      case MyDslPackage.COMPOUND_TASK__LOCATION:
        setLocation((Location)null);
        return;
      case MyDslPackage.COMPOUND_TASK__ORDERED:
        setOrdered(ORDERED_EDEFAULT);
        return;
      case MyDslPackage.COMPOUND_TASK__CONSECUTIVE:
        setConsecutive(CONSECUTIVE_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MyDslPackage.COMPOUND_TASK__CAN_DO_TASK:
        return canDoTask != null && !canDoTask.isEmpty();
      case MyDslPackage.COMPOUND_TASK__LOCATION:
        return location != null;
      case MyDslPackage.COMPOUND_TASK__ORDERED:
        return ordered != ORDERED_EDEFAULT;
      case MyDslPackage.COMPOUND_TASK__CONSECUTIVE:
        return consecutive != CONSECUTIVE_EDEFAULT;
    }
    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(" (ordered: ");
    result.append(ordered);
    result.append(", consecutive: ");
    result.append(consecutive);
    result.append(')');
    return result.toString();
  }

} //CompoundTaskImpl
