/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.impl;

import fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.Function;
import fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.Parameter;
import fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.Type;
import fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.VhdlamsPackage;

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

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

import org.eclipse.emf.ecore.util.EcoreUtil;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Parameter</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.impl.ParameterImpl#getOwnerFunction <em>Owner Function</em>}</li>
 *   <li>{@link fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.impl.ParameterImpl#getOwnerProcess <em>Owner Process</em>}</li>
 *   <li>{@link fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.impl.ParameterImpl#getName <em>Name</em>}</li>
 *   <li>{@link fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.impl.ParameterImpl#getType <em>Type</em>}</li>
 *   <li>{@link fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.impl.ParameterImpl#getDefault <em>Default</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ParameterImpl extends EObjectImpl implements Parameter {
	/**
	 * 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 cached value of the '{@link #getType() <em>Type</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected Type type;

	/**
	 * The default value of the '{@link #getDefault() <em>Default</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDefault()
	 * @generated
	 * @ordered
	 */
	protected static final String DEFAULT_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getDefault() <em>Default</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDefault()
	 * @generated
	 * @ordered
	 */
	protected String default_ = DEFAULT_EDEFAULT;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Function getOwnerFunction() {
		if (eContainerFeatureID() != VhdlamsPackage.PARAMETER__OWNER_FUNCTION) return null;
		return (Function)eContainer();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetOwnerFunction(Function newOwnerFunction, NotificationChain msgs) {
		msgs = eBasicSetContainer((InternalEObject)newOwnerFunction, VhdlamsPackage.PARAMETER__OWNER_FUNCTION, msgs);
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOwnerFunction(Function newOwnerFunction) {
		if (newOwnerFunction != eInternalContainer() || (eContainerFeatureID() != VhdlamsPackage.PARAMETER__OWNER_FUNCTION && newOwnerFunction != null)) {
			if (EcoreUtil.isAncestor(this, newOwnerFunction))
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
			NotificationChain msgs = null;
			if (eInternalContainer() != null)
				msgs = eBasicRemoveFromContainer(msgs);
			if (newOwnerFunction != null)
				msgs = ((InternalEObject)newOwnerFunction).eInverseAdd(this, VhdlamsPackage.FUNCTION__PARAMETER, Function.class, msgs);
			msgs = basicSetOwnerFunction(newOwnerFunction, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, VhdlamsPackage.PARAMETER__OWNER_FUNCTION, newOwnerFunction, newOwnerFunction));
	}

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Type getType() {
		if (type != null && type.eIsProxy()) {
			InternalEObject oldType = (InternalEObject)type;
			type = (Type)eResolveProxy(oldType);
			if (type != oldType) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, VhdlamsPackage.PARAMETER__TYPE, oldType, type));
			}
		}
		return type;
	}

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setType(Type newType) {
		Type oldType = type;
		type = newType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, VhdlamsPackage.PARAMETER__TYPE, oldType, type));
	}

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDefault(String newDefault) {
		String oldDefault = default_;
		default_ = newDefault;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, VhdlamsPackage.PARAMETER__DEFAULT, oldDefault, default_));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.Process getOwnerProcess() {
		if (eContainerFeatureID() != VhdlamsPackage.PARAMETER__OWNER_PROCESS) return null;
		return (fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.Process)eContainer();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetOwnerProcess(fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.Process newOwnerProcess, NotificationChain msgs) {
		msgs = eBasicSetContainer((InternalEObject)newOwnerProcess, VhdlamsPackage.PARAMETER__OWNER_PROCESS, msgs);
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOwnerProcess(fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.Process newOwnerProcess) {
		if (newOwnerProcess != eInternalContainer() || (eContainerFeatureID() != VhdlamsPackage.PARAMETER__OWNER_PROCESS && newOwnerProcess != null)) {
			if (EcoreUtil.isAncestor(this, newOwnerProcess))
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
			NotificationChain msgs = null;
			if (eInternalContainer() != null)
				msgs = eBasicRemoveFromContainer(msgs);
			if (newOwnerProcess != null)
				msgs = ((InternalEObject)newOwnerProcess).eInverseAdd(this, VhdlamsPackage.PROCESS__PARAMETER, fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.Process.class, msgs);
			msgs = basicSetOwnerProcess(newOwnerProcess, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, VhdlamsPackage.PARAMETER__OWNER_PROCESS, newOwnerProcess, newOwnerProcess));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case VhdlamsPackage.PARAMETER__OWNER_FUNCTION:
				if (eInternalContainer() != null)
					msgs = eBasicRemoveFromContainer(msgs);
				return basicSetOwnerFunction((Function)otherEnd, msgs);
			case VhdlamsPackage.PARAMETER__OWNER_PROCESS:
				if (eInternalContainer() != null)
					msgs = eBasicRemoveFromContainer(msgs);
				return basicSetOwnerProcess((fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.Process)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case VhdlamsPackage.PARAMETER__OWNER_FUNCTION:
				return basicSetOwnerFunction(null, msgs);
			case VhdlamsPackage.PARAMETER__OWNER_PROCESS:
				return basicSetOwnerProcess(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
		switch (eContainerFeatureID()) {
			case VhdlamsPackage.PARAMETER__OWNER_FUNCTION:
				return eInternalContainer().eInverseRemove(this, VhdlamsPackage.FUNCTION__PARAMETER, Function.class, msgs);
			case VhdlamsPackage.PARAMETER__OWNER_PROCESS:
				return eInternalContainer().eInverseRemove(this, VhdlamsPackage.PROCESS__PARAMETER, fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.Process.class, msgs);
		}
		return super.eBasicRemoveFromContainerFeature(msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case VhdlamsPackage.PARAMETER__OWNER_FUNCTION:
				return getOwnerFunction();
			case VhdlamsPackage.PARAMETER__OWNER_PROCESS:
				return getOwnerProcess();
			case VhdlamsPackage.PARAMETER__NAME:
				return getName();
			case VhdlamsPackage.PARAMETER__TYPE:
				if (resolve) return getType();
				return basicGetType();
			case VhdlamsPackage.PARAMETER__DEFAULT:
				return getDefault();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case VhdlamsPackage.PARAMETER__OWNER_FUNCTION:
				setOwnerFunction((Function)newValue);
				return;
			case VhdlamsPackage.PARAMETER__OWNER_PROCESS:
				setOwnerProcess((fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.Process)newValue);
				return;
			case VhdlamsPackage.PARAMETER__NAME:
				setName((String)newValue);
				return;
			case VhdlamsPackage.PARAMETER__TYPE:
				setType((Type)newValue);
				return;
			case VhdlamsPackage.PARAMETER__DEFAULT:
				setDefault((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case VhdlamsPackage.PARAMETER__OWNER_FUNCTION:
				setOwnerFunction((Function)null);
				return;
			case VhdlamsPackage.PARAMETER__OWNER_PROCESS:
				setOwnerProcess((fr.femtost.disc.eclipse.vhdlamsmetamodel.vhdlams.Process)null);
				return;
			case VhdlamsPackage.PARAMETER__NAME:
				setName(NAME_EDEFAULT);
				return;
			case VhdlamsPackage.PARAMETER__TYPE:
				setType((Type)null);
				return;
			case VhdlamsPackage.PARAMETER__DEFAULT:
				setDefault(DEFAULT_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case VhdlamsPackage.PARAMETER__OWNER_FUNCTION:
				return getOwnerFunction() != null;
			case VhdlamsPackage.PARAMETER__OWNER_PROCESS:
				return getOwnerProcess() != null;
			case VhdlamsPackage.PARAMETER__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case VhdlamsPackage.PARAMETER__TYPE:
				return type != null;
			case VhdlamsPackage.PARAMETER__DEFAULT:
				return DEFAULT_EDEFAULT == null ? default_ != null : !DEFAULT_EDEFAULT.equals(default_);
		}
		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(", default: ");
		result.append(default_);
		result.append(')');
		return result.toString();
	}

} //ParameterImpl
