/**
 */
package org.etsi.mts.tdl.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

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.EObjectResolvingEList;

import org.etsi.mts.tdl.ElementImport;
import org.etsi.mts.tdl.PackageableElement;
import org.etsi.mts.tdl.tdlPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Element Import</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.etsi.mts.tdl.impl.ElementImportImpl#getImportedElement <em>Imported Element</em>}</li>
 *   <li>{@link org.etsi.mts.tdl.impl.ElementImportImpl#getImportedPackage <em>Imported Package</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ElementImportImpl extends ElementImpl implements ElementImport
{
	/**
	 * The cached value of the '{@link #getImportedElement() <em>Imported Element</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getImportedElement()
	 * @generated
	 * @ordered
	 */
	protected EList<PackageableElement> importedElement;

	/**
	 * The cached value of the '{@link #getImportedPackage() <em>Imported Package</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getImportedPackage()
	 * @generated
	 * @ordered
	 */
	protected org.etsi.mts.tdl.Package importedPackage;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EList<PackageableElement> getImportedElement()
	{
		if (importedElement == null)
		{
			importedElement = new EObjectResolvingEList<PackageableElement>(PackageableElement.class, this, tdlPackage.ELEMENT_IMPORT__IMPORTED_ELEMENT);
		}
		return importedElement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public org.etsi.mts.tdl.Package getImportedPackage()
	{
		if (importedPackage != null && importedPackage.eIsProxy())
		{
			InternalEObject oldImportedPackage = (InternalEObject)importedPackage;
			importedPackage = (org.etsi.mts.tdl.Package)eResolveProxy(oldImportedPackage);
			if (importedPackage != oldImportedPackage)
			{
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, tdlPackage.ELEMENT_IMPORT__IMPORTED_PACKAGE, oldImportedPackage, importedPackage));
			}
		}
		return importedPackage;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public org.etsi.mts.tdl.Package basicGetImportedPackage()
	{
		return importedPackage;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setImportedPackage(org.etsi.mts.tdl.Package newImportedPackage)
	{
		org.etsi.mts.tdl.Package oldImportedPackage = importedPackage;
		importedPackage = newImportedPackage;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, tdlPackage.ELEMENT_IMPORT__IMPORTED_PACKAGE, oldImportedPackage, importedPackage));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType)
	{
		switch (featureID)
		{
			case tdlPackage.ELEMENT_IMPORT__IMPORTED_ELEMENT:
				return getImportedElement();
			case tdlPackage.ELEMENT_IMPORT__IMPORTED_PACKAGE:
				if (resolve) return getImportedPackage();
				return basicGetImportedPackage();
		}
		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 tdlPackage.ELEMENT_IMPORT__IMPORTED_ELEMENT:
				getImportedElement().clear();
				getImportedElement().addAll((Collection<? extends PackageableElement>)newValue);
				return;
			case tdlPackage.ELEMENT_IMPORT__IMPORTED_PACKAGE:
				setImportedPackage((org.etsi.mts.tdl.Package)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID)
	{
		switch (featureID)
		{
			case tdlPackage.ELEMENT_IMPORT__IMPORTED_ELEMENT:
				getImportedElement().clear();
				return;
			case tdlPackage.ELEMENT_IMPORT__IMPORTED_PACKAGE:
				setImportedPackage((org.etsi.mts.tdl.Package)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID)
	{
		switch (featureID)
		{
			case tdlPackage.ELEMENT_IMPORT__IMPORTED_ELEMENT:
				return importedElement != null && !importedElement.isEmpty();
			case tdlPackage.ELEMENT_IMPORT__IMPORTED_PACKAGE:
				return importedPackage != null;
		}
		return super.eIsSet(featureID);
	}

} //ElementImportImpl
