/**
 */
package org.xtext.example.mydsl6.myDsl6.impl;

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.xtext.example.mydsl6.myDsl6.Context;
import org.xtext.example.mydsl6.myDsl6.MyDsl6Package;
import org.xtext.example.mydsl6.myDsl6.WebApplication;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Context</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.mydsl6.myDsl6.impl.ContextImpl#getApp <em>App</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ContextImpl extends ContentextUnitImpl implements Context
{
  /**
   * The cached value of the '{@link #getApp() <em>App</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getApp()
   * @generated
   * @ordered
   */
  protected WebApplication app;

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public WebApplication getApp()
  {
    return app;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetApp(WebApplication newApp, NotificationChain msgs)
  {
    WebApplication oldApp = app;
    app = newApp;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MyDsl6Package.CONTEXT__APP, oldApp, newApp);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setApp(WebApplication newApp)
  {
    if (newApp != app)
    {
      NotificationChain msgs = null;
      if (app != null)
        msgs = ((InternalEObject)app).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MyDsl6Package.CONTEXT__APP, null, msgs);
      if (newApp != null)
        msgs = ((InternalEObject)newApp).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MyDsl6Package.CONTEXT__APP, null, msgs);
      msgs = basicSetApp(newApp, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDsl6Package.CONTEXT__APP, newApp, newApp));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MyDsl6Package.CONTEXT__APP:
        return basicSetApp(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 MyDsl6Package.CONTEXT__APP:
        return getApp();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MyDsl6Package.CONTEXT__APP:
        setApp((WebApplication)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MyDsl6Package.CONTEXT__APP:
        setApp((WebApplication)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MyDsl6Package.CONTEXT__APP:
        return app != null;
    }
    return super.eIsSet(featureID);
  }

} //ContextImpl
