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

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.etsi.mts.tdl.structuredobjectives.EntityBinding;
import org.etsi.mts.tdl.structuredobjectives.EntityReference;
import org.etsi.mts.tdl.structuredobjectives.StructuredObjectivesPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Entity Binding</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.etsi.mts.tdl.structuredobjectives.impl.EntityBindingImpl#getTemplateEntity <em>Template Entity</em>}</li>
 *   <li>{@link org.etsi.mts.tdl.structuredobjectives.impl.EntityBindingImpl#getOccurrenceEntity <em>Occurrence Entity</em>}</li>
 * </ul>
 *
 * @generated
 */
public class EntityBindingImpl extends ElementImpl implements EntityBinding
{
	/**
	 * The cached value of the '{@link #getTemplateEntity() <em>Template Entity</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTemplateEntity()
	 * @generated
	 * @ordered
	 */
	protected EntityReference templateEntity;

	/**
	 * The cached value of the '{@link #getOccurrenceEntity() <em>Occurrence Entity</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOccurrenceEntity()
	 * @generated
	 * @ordered
	 */
	protected EntityReference occurrenceEntity;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EntityReference getTemplateEntity()
	{
		return templateEntity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetTemplateEntity(EntityReference newTemplateEntity, NotificationChain msgs)
	{
		EntityReference oldTemplateEntity = templateEntity;
		templateEntity = newTemplateEntity;
		if (eNotificationRequired())
		{
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.ENTITY_BINDING__TEMPLATE_ENTITY, oldTemplateEntity, newTemplateEntity);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setTemplateEntity(EntityReference newTemplateEntity)
	{
		if (newTemplateEntity != templateEntity)
		{
			NotificationChain msgs = null;
			if (templateEntity != null)
				msgs = ((InternalEObject)templateEntity).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.ENTITY_BINDING__TEMPLATE_ENTITY, null, msgs);
			if (newTemplateEntity != null)
				msgs = ((InternalEObject)newTemplateEntity).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.ENTITY_BINDING__TEMPLATE_ENTITY, null, msgs);
			msgs = basicSetTemplateEntity(newTemplateEntity, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.ENTITY_BINDING__TEMPLATE_ENTITY, newTemplateEntity, newTemplateEntity));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EntityReference getOccurrenceEntity()
	{
		return occurrenceEntity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetOccurrenceEntity(EntityReference newOccurrenceEntity, NotificationChain msgs)
	{
		EntityReference oldOccurrenceEntity = occurrenceEntity;
		occurrenceEntity = newOccurrenceEntity;
		if (eNotificationRequired())
		{
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.ENTITY_BINDING__OCCURRENCE_ENTITY, oldOccurrenceEntity, newOccurrenceEntity);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setOccurrenceEntity(EntityReference newOccurrenceEntity)
	{
		if (newOccurrenceEntity != occurrenceEntity)
		{
			NotificationChain msgs = null;
			if (occurrenceEntity != null)
				msgs = ((InternalEObject)occurrenceEntity).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.ENTITY_BINDING__OCCURRENCE_ENTITY, null, msgs);
			if (newOccurrenceEntity != null)
				msgs = ((InternalEObject)newOccurrenceEntity).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StructuredObjectivesPackage.ENTITY_BINDING__OCCURRENCE_ENTITY, null, msgs);
			msgs = basicSetOccurrenceEntity(newOccurrenceEntity, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StructuredObjectivesPackage.ENTITY_BINDING__OCCURRENCE_ENTITY, newOccurrenceEntity, newOccurrenceEntity));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.ENTITY_BINDING__TEMPLATE_ENTITY:
				return basicSetTemplateEntity(null, msgs);
			case StructuredObjectivesPackage.ENTITY_BINDING__OCCURRENCE_ENTITY:
				return basicSetOccurrenceEntity(null, 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 StructuredObjectivesPackage.ENTITY_BINDING__TEMPLATE_ENTITY:
				return getTemplateEntity();
			case StructuredObjectivesPackage.ENTITY_BINDING__OCCURRENCE_ENTITY:
				return getOccurrenceEntity();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.ENTITY_BINDING__TEMPLATE_ENTITY:
				setTemplateEntity((EntityReference)newValue);
				return;
			case StructuredObjectivesPackage.ENTITY_BINDING__OCCURRENCE_ENTITY:
				setOccurrenceEntity((EntityReference)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.ENTITY_BINDING__TEMPLATE_ENTITY:
				setTemplateEntity((EntityReference)null);
				return;
			case StructuredObjectivesPackage.ENTITY_BINDING__OCCURRENCE_ENTITY:
				setOccurrenceEntity((EntityReference)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID)
	{
		switch (featureID)
		{
			case StructuredObjectivesPackage.ENTITY_BINDING__TEMPLATE_ENTITY:
				return templateEntity != null;
			case StructuredObjectivesPackage.ENTITY_BINDING__OCCURRENCE_ENTITY:
				return occurrenceEntity != null;
		}
		return super.eIsSet(featureID);
	}

} //EntityBindingImpl
