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

import java.lang.reflect.InvocationTargetException;

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

import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.WrappedException;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

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

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Extension</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.etsi.mts.tdl.impl.ExtensionImpl#getExtending <em>Extending</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ExtensionImpl extends ElementImpl implements Extension
{
	/**
	 * The cached value of the '{@link #getExtending() <em>Extending</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getExtending()
	 * @generated
	 * @ordered
	 */
	protected PackageableElement extending;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public PackageableElement getExtending()
	{
		if (extending != null && extending.eIsProxy())
		{
			InternalEObject oldExtending = (InternalEObject)extending;
			extending = (PackageableElement)eResolveProxy(oldExtending);
			if (extending != oldExtending)
			{
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, tdlPackage.EXTENSION__EXTENDING, oldExtending, extending));
			}
		}
		return extending;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PackageableElement basicGetExtending()
	{
		return extending;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setExtending(PackageableElement newExtending)
	{
		PackageableElement oldExtending = extending;
		extending = newExtending;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, tdlPackage.EXTENSION__EXTENDING, oldExtending, extending));
	}

	/**
	 * The cached invocation delegate for the '{@link #transitiveExtending() <em>Transitive Extending</em>}' operation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #transitiveExtending()
	 * @generated
	 * @ordered
	 */
	protected static final EOperation.Internal.InvocationDelegate TRANSITIVE_EXTENDING__EINVOCATION_DELEGATE = ((EOperation.Internal)tdlPackage.Literals.EXTENSION___TRANSITIVE_EXTENDING).getInvocationDelegate();

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public EList<Extension> transitiveExtending()
	{
		try
		{
			return (EList<Extension>)TRANSITIVE_EXTENDING__EINVOCATION_DELEGATE.dynamicInvoke(this, null);
		}
		catch (InvocationTargetException ite)
		{
			throw new WrappedException(ite);
		}
	}

	/**
	 * The cached invocation delegate for the '{@link #isExtending(org.etsi.mts.tdl.PackageableElement) <em>Is Extending</em>}' operation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isExtending(org.etsi.mts.tdl.PackageableElement)
	 * @generated
	 * @ordered
	 */
	protected static final EOperation.Internal.InvocationDelegate IS_EXTENDING_PACKAGEABLE_ELEMENT__EINVOCATION_DELEGATE = ((EOperation.Internal)tdlPackage.Literals.EXTENSION___IS_EXTENDING__PACKAGEABLEELEMENT).getInvocationDelegate();

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Boolean isExtending(PackageableElement e)
	{
		try
		{
			return (Boolean)IS_EXTENDING_PACKAGEABLE_ELEMENT__EINVOCATION_DELEGATE.dynamicInvoke(this, new BasicEList.UnmodifiableEList<Object>(1, new Object[]{e}));
		}
		catch (InvocationTargetException ite)
		{
			throw new WrappedException(ite);
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType)
	{
		switch (featureID)
		{
			case tdlPackage.EXTENSION__EXTENDING:
				if (resolve) return getExtending();
				return basicGetExtending();
		}
		return super.eGet(featureID, resolve, coreType);
	}

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID)
	{
		switch (featureID)
		{
			case tdlPackage.EXTENSION__EXTENDING:
				setExtending((PackageableElement)null);
				return;
		}
		super.eUnset(featureID);
	}

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException
	{
		switch (operationID)
		{
			case tdlPackage.EXTENSION___TRANSITIVE_EXTENDING:
				return transitiveExtending();
			case tdlPackage.EXTENSION___IS_EXTENDING__PACKAGEABLEELEMENT:
				return isExtending((PackageableElement)arguments.get(0));
		}
		return super.eInvoke(operationID, arguments);
	}

} //ExtensionImpl
