/**
 * generated by Xtext 2.9.2
 */
package com.justeat.mickeydb.mickeyLang.impl;

import com.justeat.mickeydb.mickeyLang.ActionStatement;
import com.justeat.mickeydb.mickeyLang.ContentNotificationUri;
import com.justeat.mickeydb.mickeyLang.ContentUri;
import com.justeat.mickeydb.mickeyLang.ContentUriQueryParam;
import com.justeat.mickeydb.mickeyLang.MickeyLangPackage;
import com.justeat.mickeydb.mickeyLang.TableDefinition;

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.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Action Statement</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link com.justeat.mickeydb.mickeyLang.impl.ActionStatementImpl#getName <em>Name</em>}</li>
 *   <li>{@link com.justeat.mickeydb.mickeyLang.impl.ActionStatementImpl#getUri <em>Uri</em>}</li>
 *   <li>{@link com.justeat.mickeydb.mickeyLang.impl.ActionStatementImpl#getType <em>Type</em>}</li>
 *   <li>{@link com.justeat.mickeydb.mickeyLang.impl.ActionStatementImpl#isUnique <em>Unique</em>}</li>
 *   <li>{@link com.justeat.mickeydb.mickeyLang.impl.ActionStatementImpl#getParams <em>Params</em>}</li>
 *   <li>{@link com.justeat.mickeydb.mickeyLang.impl.ActionStatementImpl#getNotifications <em>Notifications</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ActionStatementImpl extends MickeyBlockImpl implements ActionStatement
{
  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

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

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

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

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

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

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

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

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

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MickeyLangPackage.ACTION_STATEMENT__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ContentUri getUri()
  {
    return uri;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetUri(ContentUri newUri, NotificationChain msgs)
  {
    ContentUri oldUri = uri;
    uri = newUri;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MickeyLangPackage.ACTION_STATEMENT__URI, oldUri, newUri);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setUri(ContentUri newUri)
  {
    if (newUri != uri)
    {
      NotificationChain msgs = null;
      if (uri != null)
        msgs = ((InternalEObject)uri).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MickeyLangPackage.ACTION_STATEMENT__URI, null, msgs);
      if (newUri != null)
        msgs = ((InternalEObject)newUri).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MickeyLangPackage.ACTION_STATEMENT__URI, null, msgs);
      msgs = basicSetUri(newUri, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MickeyLangPackage.ACTION_STATEMENT__URI, newUri, newUri));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public TableDefinition getType()
  {
    if (type != null && type.eIsProxy())
    {
      InternalEObject oldType = (InternalEObject)type;
      type = (TableDefinition)eResolveProxy(oldType);
      if (type != oldType)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, MickeyLangPackage.ACTION_STATEMENT__TYPE, oldType, type));
      }
    }
    return type;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public TableDefinition basicGetType()
  {
    return type;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setType(TableDefinition newType)
  {
    TableDefinition oldType = type;
    type = newType;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MickeyLangPackage.ACTION_STATEMENT__TYPE, oldType, type));
  }

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setUnique(boolean newUnique)
  {
    boolean oldUnique = unique;
    unique = newUnique;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MickeyLangPackage.ACTION_STATEMENT__UNIQUE, oldUnique, unique));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<ContentUriQueryParam> getParams()
  {
    if (params == null)
    {
      params = new EObjectContainmentEList<ContentUriQueryParam>(ContentUriQueryParam.class, this, MickeyLangPackage.ACTION_STATEMENT__PARAMS);
    }
    return params;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<ContentNotificationUri> getNotifications()
  {
    if (notifications == null)
    {
      notifications = new EObjectContainmentEList<ContentNotificationUri>(ContentNotificationUri.class, this, MickeyLangPackage.ACTION_STATEMENT__NOTIFICATIONS);
    }
    return notifications;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MickeyLangPackage.ACTION_STATEMENT__URI:
        return basicSetUri(null, msgs);
      case MickeyLangPackage.ACTION_STATEMENT__PARAMS:
        return ((InternalEList<?>)getParams()).basicRemove(otherEnd, msgs);
      case MickeyLangPackage.ACTION_STATEMENT__NOTIFICATIONS:
        return ((InternalEList<?>)getNotifications()).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 MickeyLangPackage.ACTION_STATEMENT__NAME:
        return getName();
      case MickeyLangPackage.ACTION_STATEMENT__URI:
        return getUri();
      case MickeyLangPackage.ACTION_STATEMENT__TYPE:
        if (resolve) return getType();
        return basicGetType();
      case MickeyLangPackage.ACTION_STATEMENT__UNIQUE:
        return isUnique();
      case MickeyLangPackage.ACTION_STATEMENT__PARAMS:
        return getParams();
      case MickeyLangPackage.ACTION_STATEMENT__NOTIFICATIONS:
        return getNotifications();
    }
    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 MickeyLangPackage.ACTION_STATEMENT__NAME:
        setName((String)newValue);
        return;
      case MickeyLangPackage.ACTION_STATEMENT__URI:
        setUri((ContentUri)newValue);
        return;
      case MickeyLangPackage.ACTION_STATEMENT__TYPE:
        setType((TableDefinition)newValue);
        return;
      case MickeyLangPackage.ACTION_STATEMENT__UNIQUE:
        setUnique((Boolean)newValue);
        return;
      case MickeyLangPackage.ACTION_STATEMENT__PARAMS:
        getParams().clear();
        getParams().addAll((Collection<? extends ContentUriQueryParam>)newValue);
        return;
      case MickeyLangPackage.ACTION_STATEMENT__NOTIFICATIONS:
        getNotifications().clear();
        getNotifications().addAll((Collection<? extends ContentNotificationUri>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MickeyLangPackage.ACTION_STATEMENT__NAME:
        setName(NAME_EDEFAULT);
        return;
      case MickeyLangPackage.ACTION_STATEMENT__URI:
        setUri((ContentUri)null);
        return;
      case MickeyLangPackage.ACTION_STATEMENT__TYPE:
        setType((TableDefinition)null);
        return;
      case MickeyLangPackage.ACTION_STATEMENT__UNIQUE:
        setUnique(UNIQUE_EDEFAULT);
        return;
      case MickeyLangPackage.ACTION_STATEMENT__PARAMS:
        getParams().clear();
        return;
      case MickeyLangPackage.ACTION_STATEMENT__NOTIFICATIONS:
        getNotifications().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MickeyLangPackage.ACTION_STATEMENT__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case MickeyLangPackage.ACTION_STATEMENT__URI:
        return uri != null;
      case MickeyLangPackage.ACTION_STATEMENT__TYPE:
        return type != null;
      case MickeyLangPackage.ACTION_STATEMENT__UNIQUE:
        return unique != UNIQUE_EDEFAULT;
      case MickeyLangPackage.ACTION_STATEMENT__PARAMS:
        return params != null && !params.isEmpty();
      case MickeyLangPackage.ACTION_STATEMENT__NOTIFICATIONS:
        return notifications != null && !notifications.isEmpty();
    }
    return super.eIsSet(featureID);
  }

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

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(", unique: ");
    result.append(unique);
    result.append(')');
    return result.toString();
  }

} //ActionStatementImpl
