/**
 * 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.notify.NotificationChain;

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.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.xtext.example.mydsl.myDsl.Mission;
import org.xtext.example.mydsl.myDsl.MyDslPackage;
import org.xtext.example.mydsl.myDsl.ProblemSpecification;
import org.xtext.example.mydsl.myDsl.QoS;
import org.xtext.example.mydsl.myDsl.RobotsModel;
import org.xtext.example.mydsl.myDsl.TasksModel;
import org.xtext.example.mydsl.myDsl.WorldModel;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Problem Specification</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.ProblemSpecificationImpl#getWorldModel <em>World Model</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.ProblemSpecificationImpl#getTasksModel <em>Tasks Model</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.ProblemSpecificationImpl#getRobotsModel <em>Robots Model</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.ProblemSpecificationImpl#getMission <em>Mission</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.ProblemSpecificationImpl#getQos <em>Qos</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ProblemSpecificationImpl extends MinimalEObjectImpl.Container implements ProblemSpecification
{
  /**
   * The cached value of the '{@link #getWorldModel() <em>World Model</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getWorldModel()
   * @generated
   * @ordered
   */
  protected EList<WorldModel> worldModel;

  /**
   * The cached value of the '{@link #getTasksModel() <em>Tasks Model</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTasksModel()
   * @generated
   * @ordered
   */
  protected EList<TasksModel> tasksModel;

  /**
   * The cached value of the '{@link #getRobotsModel() <em>Robots Model</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRobotsModel()
   * @generated
   * @ordered
   */
  protected RobotsModel robotsModel;

  /**
   * The cached value of the '{@link #getMission() <em>Mission</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMission()
   * @generated
   * @ordered
   */
  protected EList<Mission> mission;

  /**
   * The cached value of the '{@link #getQos() <em>Qos</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getQos()
   * @generated
   * @ordered
   */
  protected EList<QoS> qos;

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public EList<WorldModel> getWorldModel()
  {
    if (worldModel == null)
    {
      worldModel = new EObjectContainmentEList<WorldModel>(WorldModel.class, this, MyDslPackage.PROBLEM_SPECIFICATION__WORLD_MODEL);
    }
    return worldModel;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public EList<TasksModel> getTasksModel()
  {
    if (tasksModel == null)
    {
      tasksModel = new EObjectContainmentEList<TasksModel>(TasksModel.class, this, MyDslPackage.PROBLEM_SPECIFICATION__TASKS_MODEL);
    }
    return tasksModel;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public RobotsModel getRobotsModel()
  {
    return robotsModel;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetRobotsModel(RobotsModel newRobotsModel, NotificationChain msgs)
  {
    RobotsModel oldRobotsModel = robotsModel;
    robotsModel = newRobotsModel;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MyDslPackage.PROBLEM_SPECIFICATION__ROBOTS_MODEL, oldRobotsModel, newRobotsModel);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void setRobotsModel(RobotsModel newRobotsModel)
  {
    if (newRobotsModel != robotsModel)
    {
      NotificationChain msgs = null;
      if (robotsModel != null)
        msgs = ((InternalEObject)robotsModel).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.PROBLEM_SPECIFICATION__ROBOTS_MODEL, null, msgs);
      if (newRobotsModel != null)
        msgs = ((InternalEObject)newRobotsModel).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.PROBLEM_SPECIFICATION__ROBOTS_MODEL, null, msgs);
      msgs = basicSetRobotsModel(newRobotsModel, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.PROBLEM_SPECIFICATION__ROBOTS_MODEL, newRobotsModel, newRobotsModel));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public EList<Mission> getMission()
  {
    if (mission == null)
    {
      mission = new EObjectContainmentEList<Mission>(Mission.class, this, MyDslPackage.PROBLEM_SPECIFICATION__MISSION);
    }
    return mission;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public EList<QoS> getQos()
  {
    if (qos == null)
    {
      qos = new EObjectContainmentEList<QoS>(QoS.class, this, MyDslPackage.PROBLEM_SPECIFICATION__QOS);
    }
    return qos;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MyDslPackage.PROBLEM_SPECIFICATION__WORLD_MODEL:
        return ((InternalEList<?>)getWorldModel()).basicRemove(otherEnd, msgs);
      case MyDslPackage.PROBLEM_SPECIFICATION__TASKS_MODEL:
        return ((InternalEList<?>)getTasksModel()).basicRemove(otherEnd, msgs);
      case MyDslPackage.PROBLEM_SPECIFICATION__ROBOTS_MODEL:
        return basicSetRobotsModel(null, msgs);
      case MyDslPackage.PROBLEM_SPECIFICATION__MISSION:
        return ((InternalEList<?>)getMission()).basicRemove(otherEnd, msgs);
      case MyDslPackage.PROBLEM_SPECIFICATION__QOS:
        return ((InternalEList<?>)getQos()).basicRemove(otherEnd, 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 MyDslPackage.PROBLEM_SPECIFICATION__WORLD_MODEL:
        return getWorldModel();
      case MyDslPackage.PROBLEM_SPECIFICATION__TASKS_MODEL:
        return getTasksModel();
      case MyDslPackage.PROBLEM_SPECIFICATION__ROBOTS_MODEL:
        return getRobotsModel();
      case MyDslPackage.PROBLEM_SPECIFICATION__MISSION:
        return getMission();
      case MyDslPackage.PROBLEM_SPECIFICATION__QOS:
        return getQos();
    }
    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.PROBLEM_SPECIFICATION__WORLD_MODEL:
        getWorldModel().clear();
        getWorldModel().addAll((Collection<? extends WorldModel>)newValue);
        return;
      case MyDslPackage.PROBLEM_SPECIFICATION__TASKS_MODEL:
        getTasksModel().clear();
        getTasksModel().addAll((Collection<? extends TasksModel>)newValue);
        return;
      case MyDslPackage.PROBLEM_SPECIFICATION__ROBOTS_MODEL:
        setRobotsModel((RobotsModel)newValue);
        return;
      case MyDslPackage.PROBLEM_SPECIFICATION__MISSION:
        getMission().clear();
        getMission().addAll((Collection<? extends Mission>)newValue);
        return;
      case MyDslPackage.PROBLEM_SPECIFICATION__QOS:
        getQos().clear();
        getQos().addAll((Collection<? extends QoS>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MyDslPackage.PROBLEM_SPECIFICATION__WORLD_MODEL:
        getWorldModel().clear();
        return;
      case MyDslPackage.PROBLEM_SPECIFICATION__TASKS_MODEL:
        getTasksModel().clear();
        return;
      case MyDslPackage.PROBLEM_SPECIFICATION__ROBOTS_MODEL:
        setRobotsModel((RobotsModel)null);
        return;
      case MyDslPackage.PROBLEM_SPECIFICATION__MISSION:
        getMission().clear();
        return;
      case MyDslPackage.PROBLEM_SPECIFICATION__QOS:
        getQos().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MyDslPackage.PROBLEM_SPECIFICATION__WORLD_MODEL:
        return worldModel != null && !worldModel.isEmpty();
      case MyDslPackage.PROBLEM_SPECIFICATION__TASKS_MODEL:
        return tasksModel != null && !tasksModel.isEmpty();
      case MyDslPackage.PROBLEM_SPECIFICATION__ROBOTS_MODEL:
        return robotsModel != null;
      case MyDslPackage.PROBLEM_SPECIFICATION__MISSION:
        return mission != null && !mission.isEmpty();
      case MyDslPackage.PROBLEM_SPECIFICATION__QOS:
        return qos != null && !qos.isEmpty();
    }
    return super.eIsSet(featureID);
  }

} //ProblemSpecificationImpl
