/**
 */
package org.xtext.example.mydsl6.myDsl6.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.mydsl6.myDsl6.Field;
import org.xtext.example.mydsl6.myDsl6.MyDsl6Package;
import org.xtext.example.mydsl6.myDsl6.Type;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.mydsl6.myDsl6.impl.TypeImpl#getParentType <em>Parent Type</em>}</li>
 *   <li>{@link org.xtext.example.mydsl6.myDsl6.impl.TypeImpl#getOwnedField <em>Owned Field</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TypeImpl extends ContentextUnitImpl implements Type
{
  /**
   * The cached value of the '{@link #getParentType() <em>Parent Type</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getParentType()
   * @generated
   * @ordered
   */
  protected Type parentType;

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

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Type getParentType()
  {
    if (parentType != null && parentType.eIsProxy())
    {
      InternalEObject oldParentType = (InternalEObject)parentType;
      parentType = (Type)eResolveProxy(oldParentType);
      if (parentType != oldParentType)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, MyDsl6Package.TYPE__PARENT_TYPE, oldParentType, parentType));
      }
    }
    return parentType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Type basicGetParentType()
  {
    return parentType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setParentType(Type newParentType)
  {
    Type oldParentType = parentType;
    parentType = newParentType;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDsl6Package.TYPE__PARENT_TYPE, oldParentType, parentType));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Field> getOwnedField()
  {
    if (ownedField == null)
    {
      ownedField = new EObjectContainmentEList<Field>(Field.class, this, MyDsl6Package.TYPE__OWNED_FIELD);
    }
    return ownedField;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MyDsl6Package.TYPE__OWNED_FIELD:
        return ((InternalEList<?>)getOwnedField()).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 MyDsl6Package.TYPE__PARENT_TYPE:
        if (resolve) return getParentType();
        return basicGetParentType();
      case MyDsl6Package.TYPE__OWNED_FIELD:
        return getOwnedField();
    }
    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 MyDsl6Package.TYPE__PARENT_TYPE:
        setParentType((Type)newValue);
        return;
      case MyDsl6Package.TYPE__OWNED_FIELD:
        getOwnedField().clear();
        getOwnedField().addAll((Collection<? extends Field>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MyDsl6Package.TYPE__PARENT_TYPE:
        setParentType((Type)null);
        return;
      case MyDsl6Package.TYPE__OWNED_FIELD:
        getOwnedField().clear();
        return;
    }
    super.eUnset(featureID);
  }

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

} //TypeImpl
