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

import org.xtext.example.mydsl.myDsl.MyDslPackage;
import org.xtext.example.mydsl.myDsl.Web;

import org.xtext.example.mydsl2.myDsl2.SitePermission;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Web</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.WebImpl#getGuID <em>Gu ID</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.WebImpl#getSitePermission <em>Site Permission</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.WebImpl#getOwnedWeb <em>Owned Web</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class WebImpl extends ContentUnitImpl implements Web
{
  /**
   * The default value of the '{@link #getGuID() <em>Gu ID</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getGuID()
   * @generated
   * @ordered
   */
  protected static final String GU_ID_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getGuID() <em>Gu ID</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getGuID()
   * @generated
   * @ordered
   */
  protected String guID = GU_ID_EDEFAULT;

  /**
   * The cached value of the '{@link #getSitePermission() <em>Site Permission</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSitePermission()
   * @generated
   * @ordered
   */
  protected SitePermission sitePermission;

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

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

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setGuID(String newGuID)
  {
    String oldGuID = guID;
    guID = newGuID;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.WEB__GU_ID, oldGuID, guID));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public SitePermission getSitePermission()
  {
    if (sitePermission != null && sitePermission.eIsProxy())
    {
      InternalEObject oldSitePermission = (InternalEObject)sitePermission;
      sitePermission = (SitePermission)eResolveProxy(oldSitePermission);
      if (sitePermission != oldSitePermission)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, MyDslPackage.WEB__SITE_PERMISSION, oldSitePermission, sitePermission));
      }
    }
    return sitePermission;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public SitePermission basicGetSitePermission()
  {
    return sitePermission;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSitePermission(SitePermission newSitePermission)
  {
    SitePermission oldSitePermission = sitePermission;
    sitePermission = newSitePermission;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.WEB__SITE_PERMISSION, oldSitePermission, sitePermission));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Web> getOwnedWeb()
  {
    if (ownedWeb == null)
    {
      ownedWeb = new EObjectContainmentEList<Web>(Web.class, this, MyDslPackage.WEB__OWNED_WEB);
    }
    return ownedWeb;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MyDslPackage.WEB__OWNED_WEB:
        return ((InternalEList<?>)getOwnedWeb()).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.WEB__GU_ID:
        return getGuID();
      case MyDslPackage.WEB__SITE_PERMISSION:
        if (resolve) return getSitePermission();
        return basicGetSitePermission();
      case MyDslPackage.WEB__OWNED_WEB:
        return getOwnedWeb();
    }
    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.WEB__GU_ID:
        setGuID((String)newValue);
        return;
      case MyDslPackage.WEB__SITE_PERMISSION:
        setSitePermission((SitePermission)newValue);
        return;
      case MyDslPackage.WEB__OWNED_WEB:
        getOwnedWeb().clear();
        getOwnedWeb().addAll((Collection<? extends Web>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MyDslPackage.WEB__GU_ID:
        setGuID(GU_ID_EDEFAULT);
        return;
      case MyDslPackage.WEB__SITE_PERMISSION:
        setSitePermission((SitePermission)null);
        return;
      case MyDslPackage.WEB__OWNED_WEB:
        getOwnedWeb().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MyDslPackage.WEB__GU_ID:
        return GU_ID_EDEFAULT == null ? guID != null : !GU_ID_EDEFAULT.equals(guID);
      case MyDslPackage.WEB__SITE_PERMISSION:
        return sitePermission != null;
      case MyDslPackage.WEB__OWNED_WEB:
        return ownedWeb != null && !ownedWeb.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(" (guID: ");
    result.append(guID);
    result.append(')');
    return result.toString();
  }

} //WebImpl
