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

import com.justeat.mickeydb.mickeyLang.GroupByExpressions;
import com.justeat.mickeydb.mickeyLang.HavingExpressions;
import com.justeat.mickeydb.mickeyLang.JoinSource;
import com.justeat.mickeydb.mickeyLang.MickeyLangPackage;
import com.justeat.mickeydb.mickeyLang.SelectExpression;
import com.justeat.mickeydb.mickeyLang.SelectList;
import com.justeat.mickeydb.mickeyLang.WhereExpressions;

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>Select Expression</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link com.justeat.mickeydb.mickeyLang.impl.SelectExpressionImpl#isDistinct <em>Distinct</em>}</li>
 *   <li>{@link com.justeat.mickeydb.mickeyLang.impl.SelectExpressionImpl#isAll <em>All</em>}</li>
 *   <li>{@link com.justeat.mickeydb.mickeyLang.impl.SelectExpressionImpl#isAllColumns <em>All Columns</em>}</li>
 *   <li>{@link com.justeat.mickeydb.mickeyLang.impl.SelectExpressionImpl#getSelectList <em>Select List</em>}</li>
 *   <li>{@link com.justeat.mickeydb.mickeyLang.impl.SelectExpressionImpl#getSource <em>Source</em>}</li>
 *   <li>{@link com.justeat.mickeydb.mickeyLang.impl.SelectExpressionImpl#getWhere <em>Where</em>}</li>
 *   <li>{@link com.justeat.mickeydb.mickeyLang.impl.SelectExpressionImpl#getGroupBy <em>Group By</em>}</li>
 *   <li>{@link com.justeat.mickeydb.mickeyLang.impl.SelectExpressionImpl#getHaving <em>Having</em>}</li>
 * </ul>
 *
 * @generated
 */
public class SelectExpressionImpl extends SelectCoreExpressionImpl implements SelectExpression
{
  /**
   * The default value of the '{@link #isDistinct() <em>Distinct</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isDistinct()
   * @generated
   * @ordered
   */
  protected static final boolean DISTINCT_EDEFAULT = false;

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

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

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

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

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

  /**
   * The cached value of the '{@link #getSelectList() <em>Select List</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSelectList()
   * @generated
   * @ordered
   */
  protected SelectList selectList;

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

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

  /**
   * The cached value of the '{@link #getGroupBy() <em>Group By</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getGroupBy()
   * @generated
   * @ordered
   */
  protected GroupByExpressions groupBy;

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

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

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDistinct(boolean newDistinct)
  {
    boolean oldDistinct = distinct;
    distinct = newDistinct;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MickeyLangPackage.SELECT_EXPRESSION__DISTINCT, oldDistinct, distinct));
  }

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAll(boolean newAll)
  {
    boolean oldAll = all;
    all = newAll;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MickeyLangPackage.SELECT_EXPRESSION__ALL, oldAll, all));
  }

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAllColumns(boolean newAllColumns)
  {
    boolean oldAllColumns = allColumns;
    allColumns = newAllColumns;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MickeyLangPackage.SELECT_EXPRESSION__ALL_COLUMNS, oldAllColumns, allColumns));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public SelectList getSelectList()
  {
    return selectList;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSelectList(SelectList newSelectList, NotificationChain msgs)
  {
    SelectList oldSelectList = selectList;
    selectList = newSelectList;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MickeyLangPackage.SELECT_EXPRESSION__SELECT_LIST, oldSelectList, newSelectList);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSelectList(SelectList newSelectList)
  {
    if (newSelectList != selectList)
    {
      NotificationChain msgs = null;
      if (selectList != null)
        msgs = ((InternalEObject)selectList).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MickeyLangPackage.SELECT_EXPRESSION__SELECT_LIST, null, msgs);
      if (newSelectList != null)
        msgs = ((InternalEObject)newSelectList).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MickeyLangPackage.SELECT_EXPRESSION__SELECT_LIST, null, msgs);
      msgs = basicSetSelectList(newSelectList, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MickeyLangPackage.SELECT_EXPRESSION__SELECT_LIST, newSelectList, newSelectList));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public JoinSource getSource()
  {
    return source;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSource(JoinSource newSource, NotificationChain msgs)
  {
    JoinSource oldSource = source;
    source = newSource;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MickeyLangPackage.SELECT_EXPRESSION__SOURCE, oldSource, newSource);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSource(JoinSource newSource)
  {
    if (newSource != source)
    {
      NotificationChain msgs = null;
      if (source != null)
        msgs = ((InternalEObject)source).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MickeyLangPackage.SELECT_EXPRESSION__SOURCE, null, msgs);
      if (newSource != null)
        msgs = ((InternalEObject)newSource).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MickeyLangPackage.SELECT_EXPRESSION__SOURCE, null, msgs);
      msgs = basicSetSource(newSource, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MickeyLangPackage.SELECT_EXPRESSION__SOURCE, newSource, newSource));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public WhereExpressions getWhere()
  {
    return where;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetWhere(WhereExpressions newWhere, NotificationChain msgs)
  {
    WhereExpressions oldWhere = where;
    where = newWhere;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MickeyLangPackage.SELECT_EXPRESSION__WHERE, oldWhere, newWhere);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setWhere(WhereExpressions newWhere)
  {
    if (newWhere != where)
    {
      NotificationChain msgs = null;
      if (where != null)
        msgs = ((InternalEObject)where).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MickeyLangPackage.SELECT_EXPRESSION__WHERE, null, msgs);
      if (newWhere != null)
        msgs = ((InternalEObject)newWhere).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MickeyLangPackage.SELECT_EXPRESSION__WHERE, null, msgs);
      msgs = basicSetWhere(newWhere, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MickeyLangPackage.SELECT_EXPRESSION__WHERE, newWhere, newWhere));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public GroupByExpressions getGroupBy()
  {
    return groupBy;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetGroupBy(GroupByExpressions newGroupBy, NotificationChain msgs)
  {
    GroupByExpressions oldGroupBy = groupBy;
    groupBy = newGroupBy;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MickeyLangPackage.SELECT_EXPRESSION__GROUP_BY, oldGroupBy, newGroupBy);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setGroupBy(GroupByExpressions newGroupBy)
  {
    if (newGroupBy != groupBy)
    {
      NotificationChain msgs = null;
      if (groupBy != null)
        msgs = ((InternalEObject)groupBy).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MickeyLangPackage.SELECT_EXPRESSION__GROUP_BY, null, msgs);
      if (newGroupBy != null)
        msgs = ((InternalEObject)newGroupBy).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MickeyLangPackage.SELECT_EXPRESSION__GROUP_BY, null, msgs);
      msgs = basicSetGroupBy(newGroupBy, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MickeyLangPackage.SELECT_EXPRESSION__GROUP_BY, newGroupBy, newGroupBy));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public HavingExpressions getHaving()
  {
    return having;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetHaving(HavingExpressions newHaving, NotificationChain msgs)
  {
    HavingExpressions oldHaving = having;
    having = newHaving;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MickeyLangPackage.SELECT_EXPRESSION__HAVING, oldHaving, newHaving);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setHaving(HavingExpressions newHaving)
  {
    if (newHaving != having)
    {
      NotificationChain msgs = null;
      if (having != null)
        msgs = ((InternalEObject)having).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MickeyLangPackage.SELECT_EXPRESSION__HAVING, null, msgs);
      if (newHaving != null)
        msgs = ((InternalEObject)newHaving).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MickeyLangPackage.SELECT_EXPRESSION__HAVING, null, msgs);
      msgs = basicSetHaving(newHaving, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MickeyLangPackage.SELECT_EXPRESSION__HAVING, newHaving, newHaving));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MickeyLangPackage.SELECT_EXPRESSION__SELECT_LIST:
        return basicSetSelectList(null, msgs);
      case MickeyLangPackage.SELECT_EXPRESSION__SOURCE:
        return basicSetSource(null, msgs);
      case MickeyLangPackage.SELECT_EXPRESSION__WHERE:
        return basicSetWhere(null, msgs);
      case MickeyLangPackage.SELECT_EXPRESSION__GROUP_BY:
        return basicSetGroupBy(null, msgs);
      case MickeyLangPackage.SELECT_EXPRESSION__HAVING:
        return basicSetHaving(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 MickeyLangPackage.SELECT_EXPRESSION__DISTINCT:
        return isDistinct();
      case MickeyLangPackage.SELECT_EXPRESSION__ALL:
        return isAll();
      case MickeyLangPackage.SELECT_EXPRESSION__ALL_COLUMNS:
        return isAllColumns();
      case MickeyLangPackage.SELECT_EXPRESSION__SELECT_LIST:
        return getSelectList();
      case MickeyLangPackage.SELECT_EXPRESSION__SOURCE:
        return getSource();
      case MickeyLangPackage.SELECT_EXPRESSION__WHERE:
        return getWhere();
      case MickeyLangPackage.SELECT_EXPRESSION__GROUP_BY:
        return getGroupBy();
      case MickeyLangPackage.SELECT_EXPRESSION__HAVING:
        return getHaving();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MickeyLangPackage.SELECT_EXPRESSION__DISTINCT:
        setDistinct((Boolean)newValue);
        return;
      case MickeyLangPackage.SELECT_EXPRESSION__ALL:
        setAll((Boolean)newValue);
        return;
      case MickeyLangPackage.SELECT_EXPRESSION__ALL_COLUMNS:
        setAllColumns((Boolean)newValue);
        return;
      case MickeyLangPackage.SELECT_EXPRESSION__SELECT_LIST:
        setSelectList((SelectList)newValue);
        return;
      case MickeyLangPackage.SELECT_EXPRESSION__SOURCE:
        setSource((JoinSource)newValue);
        return;
      case MickeyLangPackage.SELECT_EXPRESSION__WHERE:
        setWhere((WhereExpressions)newValue);
        return;
      case MickeyLangPackage.SELECT_EXPRESSION__GROUP_BY:
        setGroupBy((GroupByExpressions)newValue);
        return;
      case MickeyLangPackage.SELECT_EXPRESSION__HAVING:
        setHaving((HavingExpressions)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MickeyLangPackage.SELECT_EXPRESSION__DISTINCT:
        setDistinct(DISTINCT_EDEFAULT);
        return;
      case MickeyLangPackage.SELECT_EXPRESSION__ALL:
        setAll(ALL_EDEFAULT);
        return;
      case MickeyLangPackage.SELECT_EXPRESSION__ALL_COLUMNS:
        setAllColumns(ALL_COLUMNS_EDEFAULT);
        return;
      case MickeyLangPackage.SELECT_EXPRESSION__SELECT_LIST:
        setSelectList((SelectList)null);
        return;
      case MickeyLangPackage.SELECT_EXPRESSION__SOURCE:
        setSource((JoinSource)null);
        return;
      case MickeyLangPackage.SELECT_EXPRESSION__WHERE:
        setWhere((WhereExpressions)null);
        return;
      case MickeyLangPackage.SELECT_EXPRESSION__GROUP_BY:
        setGroupBy((GroupByExpressions)null);
        return;
      case MickeyLangPackage.SELECT_EXPRESSION__HAVING:
        setHaving((HavingExpressions)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MickeyLangPackage.SELECT_EXPRESSION__DISTINCT:
        return distinct != DISTINCT_EDEFAULT;
      case MickeyLangPackage.SELECT_EXPRESSION__ALL:
        return all != ALL_EDEFAULT;
      case MickeyLangPackage.SELECT_EXPRESSION__ALL_COLUMNS:
        return allColumns != ALL_COLUMNS_EDEFAULT;
      case MickeyLangPackage.SELECT_EXPRESSION__SELECT_LIST:
        return selectList != null;
      case MickeyLangPackage.SELECT_EXPRESSION__SOURCE:
        return source != null;
      case MickeyLangPackage.SELECT_EXPRESSION__WHERE:
        return where != null;
      case MickeyLangPackage.SELECT_EXPRESSION__GROUP_BY:
        return groupBy != null;
      case MickeyLangPackage.SELECT_EXPRESSION__HAVING:
        return having != null;
    }
    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(" (distinct: ");
    result.append(distinct);
    result.append(", all: ");
    result.append(all);
    result.append(", allColumns: ");
    result.append(allColumns);
    result.append(')');
    return result.toString();
  }

} //SelectExpressionImpl
