/*
 * This file has been developed at the University of Munich, Chair for Programming & Software Engineering.
 * 
 * This file is licensed under the Eclipse Public License (EPL) 1.0
 * 
 */
package eu.mdd4soa.smm.behaviour.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 eu.mdd4soa.smm.behaviour.ISMBehaviourPackage;
import eu.mdd4soa.smm.behaviour.Receive;
import eu.mdd4soa.smm.behaviour.Reply;

/**
 * <!-- begin-user-doc --> An implementation of the model object '
 * <em><b>Reply</b></em>'. <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 * <li>{@link eu.mdd4soa.smm.behaviour.impl.ReplyImpl#getReceive <em>Receive
 * </em>}</li>
 * </ul>
 * </p>
 * 
 * @generated
 */
public class ReplyImpl extends ServiceInteractionImpl implements Reply {
	/**
	 * The cached value of the '{@link #getReceive() <em>Receive</em>}'
	 * reference. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getReceive()
	 * @generated
	 * @ordered
	 */
	protected Receive receive;

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

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

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public Receive getReceive() {
		if (receive != null && receive.eIsProxy()) {
			InternalEObject oldReceive= (InternalEObject) receive;
			receive= (Receive) eResolveProxy(oldReceive);
			if (receive != oldReceive) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ISMBehaviourPackage.REPLY__RECEIVE, oldReceive, receive));
			}
		}
		return receive;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public Receive basicGetReceive() {
		return receive;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public NotificationChain basicSetReceive(Receive newReceive, NotificationChain msgs) {
		Receive oldReceive= receive;
		receive= newReceive;
		if (eNotificationRequired()) {
			ENotificationImpl notification= new ENotificationImpl(this, Notification.SET, ISMBehaviourPackage.REPLY__RECEIVE, oldReceive, newReceive);
			if (msgs == null)
				msgs= notification;
			else
				msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public void setReceive(Receive newReceive) {
		if (newReceive != receive) {
			NotificationChain msgs= null;
			if (receive != null)
				msgs= ((InternalEObject) receive).eInverseRemove(this, ISMBehaviourPackage.RECEIVE__REPLY, Receive.class, msgs);
			if (newReceive != null)
				msgs= ((InternalEObject) newReceive).eInverseAdd(this, ISMBehaviourPackage.RECEIVE__REPLY, Receive.class, msgs);
			msgs= basicSetReceive(newReceive, msgs);
			if (msgs != null)
				msgs.dispatch();
		} else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ISMBehaviourPackage.REPLY__RECEIVE, newReceive, newReceive));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ISMBehaviourPackage.REPLY__RECEIVE:
				if (receive != null)
					msgs= ((InternalEObject) receive).eInverseRemove(this, ISMBehaviourPackage.RECEIVE__REPLY, Receive.class, msgs);
				return basicSetReceive((Receive) 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 ISMBehaviourPackage.REPLY__RECEIVE:
				return basicSetReceive(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 ISMBehaviourPackage.REPLY__RECEIVE:
				if (resolve)
					return getReceive();
				return basicGetReceive();
		}
		return super.eGet(featureID, resolve, coreType);
	}

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

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ISMBehaviourPackage.REPLY__RECEIVE:
				setReceive((Receive) null);
				return;
		}
		super.eUnset(featureID);
	}

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

} // ReplyImpl
