/**
 */
package org.xtext.example.mydsl2.myDsl2.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.mydsl2.myDsl2.Group;
import org.xtext.example.mydsl2.myDsl2.MyDsl2Package;
import org.xtext.example.mydsl2.myDsl2.RoleAssignment;
import org.xtext.example.mydsl2.myDsl2.RoleDefinition;
import org.xtext.example.mydsl2.myDsl2.SitePermission;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Site Permission</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.mydsl2.myDsl2.impl.SitePermissionImpl#getName <em>Name</em>}</li>
 *   <li>{@link org.xtext.example.mydsl2.myDsl2.impl.SitePermissionImpl#getWebGUID <em>Web GUID</em>}</li>
 *   <li>{@link org.xtext.example.mydsl2.myDsl2.impl.SitePermissionImpl#getOwnedGroup <em>Owned Group</em>}</li>
 *   <li>{@link org.xtext.example.mydsl2.myDsl2.impl.SitePermissionImpl#getOwnedRoleDefinition <em>Owned Role Definition</em>}</li>
 *   <li>{@link org.xtext.example.mydsl2.myDsl2.impl.SitePermissionImpl#getOwnedRoleAssignments <em>Owned Role Assignments</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SitePermissionImpl extends MinimalEObjectImpl.Container implements SitePermission
{
  /**
   * 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 default value of the '{@link #getWebGUID() <em>Web GUID</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getWebGUID()
   * @generated
   * @ordered
   */
  protected static final String WEB_GUID_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getWebGUID() <em>Web GUID</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getWebGUID()
   * @generated
   * @ordered
   */
  protected String webGUID = WEB_GUID_EDEFAULT;

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

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

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

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

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

  /**
   * <!-- 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, MyDsl2Package.SITE_PERMISSION__NAME, oldName, name));
  }

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setWebGUID(String newWebGUID)
  {
    String oldWebGUID = webGUID;
    webGUID = newWebGUID;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDsl2Package.SITE_PERMISSION__WEB_GUID, oldWebGUID, webGUID));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Group> getOwnedGroup()
  {
    if (ownedGroup == null)
    {
      ownedGroup = new EObjectContainmentEList<Group>(Group.class, this, MyDsl2Package.SITE_PERMISSION__OWNED_GROUP);
    }
    return ownedGroup;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<RoleDefinition> getOwnedRoleDefinition()
  {
    if (ownedRoleDefinition == null)
    {
      ownedRoleDefinition = new EObjectContainmentEList<RoleDefinition>(RoleDefinition.class, this, MyDsl2Package.SITE_PERMISSION__OWNED_ROLE_DEFINITION);
    }
    return ownedRoleDefinition;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<RoleAssignment> getOwnedRoleAssignments()
  {
    if (ownedRoleAssignments == null)
    {
      ownedRoleAssignments = new EObjectContainmentEList<RoleAssignment>(RoleAssignment.class, this, MyDsl2Package.SITE_PERMISSION__OWNED_ROLE_ASSIGNMENTS);
    }
    return ownedRoleAssignments;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MyDsl2Package.SITE_PERMISSION__OWNED_GROUP:
        return ((InternalEList<?>)getOwnedGroup()).basicRemove(otherEnd, msgs);
      case MyDsl2Package.SITE_PERMISSION__OWNED_ROLE_DEFINITION:
        return ((InternalEList<?>)getOwnedRoleDefinition()).basicRemove(otherEnd, msgs);
      case MyDsl2Package.SITE_PERMISSION__OWNED_ROLE_ASSIGNMENTS:
        return ((InternalEList<?>)getOwnedRoleAssignments()).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 MyDsl2Package.SITE_PERMISSION__NAME:
        return getName();
      case MyDsl2Package.SITE_PERMISSION__WEB_GUID:
        return getWebGUID();
      case MyDsl2Package.SITE_PERMISSION__OWNED_GROUP:
        return getOwnedGroup();
      case MyDsl2Package.SITE_PERMISSION__OWNED_ROLE_DEFINITION:
        return getOwnedRoleDefinition();
      case MyDsl2Package.SITE_PERMISSION__OWNED_ROLE_ASSIGNMENTS:
        return getOwnedRoleAssignments();
    }
    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 MyDsl2Package.SITE_PERMISSION__NAME:
        setName((String)newValue);
        return;
      case MyDsl2Package.SITE_PERMISSION__WEB_GUID:
        setWebGUID((String)newValue);
        return;
      case MyDsl2Package.SITE_PERMISSION__OWNED_GROUP:
        getOwnedGroup().clear();
        getOwnedGroup().addAll((Collection<? extends Group>)newValue);
        return;
      case MyDsl2Package.SITE_PERMISSION__OWNED_ROLE_DEFINITION:
        getOwnedRoleDefinition().clear();
        getOwnedRoleDefinition().addAll((Collection<? extends RoleDefinition>)newValue);
        return;
      case MyDsl2Package.SITE_PERMISSION__OWNED_ROLE_ASSIGNMENTS:
        getOwnedRoleAssignments().clear();
        getOwnedRoleAssignments().addAll((Collection<? extends RoleAssignment>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MyDsl2Package.SITE_PERMISSION__NAME:
        setName(NAME_EDEFAULT);
        return;
      case MyDsl2Package.SITE_PERMISSION__WEB_GUID:
        setWebGUID(WEB_GUID_EDEFAULT);
        return;
      case MyDsl2Package.SITE_PERMISSION__OWNED_GROUP:
        getOwnedGroup().clear();
        return;
      case MyDsl2Package.SITE_PERMISSION__OWNED_ROLE_DEFINITION:
        getOwnedRoleDefinition().clear();
        return;
      case MyDsl2Package.SITE_PERMISSION__OWNED_ROLE_ASSIGNMENTS:
        getOwnedRoleAssignments().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MyDsl2Package.SITE_PERMISSION__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case MyDsl2Package.SITE_PERMISSION__WEB_GUID:
        return WEB_GUID_EDEFAULT == null ? webGUID != null : !WEB_GUID_EDEFAULT.equals(webGUID);
      case MyDsl2Package.SITE_PERMISSION__OWNED_GROUP:
        return ownedGroup != null && !ownedGroup.isEmpty();
      case MyDsl2Package.SITE_PERMISSION__OWNED_ROLE_DEFINITION:
        return ownedRoleDefinition != null && !ownedRoleDefinition.isEmpty();
      case MyDsl2Package.SITE_PERMISSION__OWNED_ROLE_ASSIGNMENTS:
        return ownedRoleAssignments != null && !ownedRoleAssignments.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(", webGUID: ");
    result.append(webGUID);
    result.append(')');
    return result.toString();
  }

} //SitePermissionImpl
