/*
 * 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.statik.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.eclipse.emf.ecore.impl.EObjectImpl;

import eu.mdd4soa.smm.behaviour.ServiceProtocol;
import eu.mdd4soa.smm.statik.ISMStatikPackage;
import eu.mdd4soa.smm.statik.InterfaceType;
import eu.mdd4soa.smm.statik.Service;

/**
 * <!-- begin-user-doc --> An implementation of the model object '
 * <em><b>Partner Point</b></em>'. <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 * <li>{@link eu.mdd4soa.smm.statik.impl.ServiceImpl#getName <em>Name</em>}</li>
 * <li>{@link eu.mdd4soa.smm.statik.impl.ServiceImpl#getInterface <em>Interface
 * </em>}</li>
 * <li>{@link eu.mdd4soa.smm.statik.impl.ServiceImpl#getProtocol <em>Protocol
 * </em>}</li>
 * </ul>
 * </p>
 * 
 * @generated
 */
public abstract class ServiceImpl extends EObjectImpl implements Service {
	/**
	 * 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 #getInterface() <em>Interface</em>}'
	 * reference. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getInterface()
	 * @generated
	 * @ordered
	 */
	protected InterfaceType interface_;

	/**
	 * The cached value of the '{@link #getProtocol() <em>Protocol</em>}'
	 * containment reference. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getProtocol()
	 * @generated
	 * @ordered
	 */
	protected ServiceProtocol protocol;

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

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

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

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public InterfaceType getInterface() {
		if (interface_ != null && interface_.eIsProxy()) {
			InternalEObject oldInterface= (InternalEObject) interface_;
			interface_= (InterfaceType) eResolveProxy(oldInterface);
			if (interface_ != oldInterface) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ISMStatikPackage.SERVICE__INTERFACE, oldInterface, interface_));
			}
		}
		return interface_;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public InterfaceType basicGetInterface() {
		return interface_;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public void setInterface(InterfaceType newInterface) {
		InterfaceType oldInterface= interface_;
		interface_= newInterface;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ISMStatikPackage.SERVICE__INTERFACE, oldInterface, interface_));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public ServiceProtocol getProtocol() {
		return protocol;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public NotificationChain basicSetProtocol(ServiceProtocol newProtocol, NotificationChain msgs) {
		ServiceProtocol oldProtocol= protocol;
		protocol= newProtocol;
		if (eNotificationRequired()) {
			ENotificationImpl notification= new ENotificationImpl(this, Notification.SET, ISMStatikPackage.SERVICE__PROTOCOL, oldProtocol,
					newProtocol);
			if (msgs == null)
				msgs= notification;
			else
				msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public void setProtocol(ServiceProtocol newProtocol) {
		if (newProtocol != protocol) {
			NotificationChain msgs= null;
			if (protocol != null)
				msgs= ((InternalEObject) protocol).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ISMStatikPackage.SERVICE__PROTOCOL, null, msgs);
			if (newProtocol != null)
				msgs= ((InternalEObject) newProtocol).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ISMStatikPackage.SERVICE__PROTOCOL, null, msgs);
			msgs= basicSetProtocol(newProtocol, msgs);
			if (msgs != null)
				msgs.dispatch();
		} else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ISMStatikPackage.SERVICE__PROTOCOL, newProtocol, newProtocol));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ISMStatikPackage.SERVICE__PROTOCOL:
				return basicSetProtocol(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 ISMStatikPackage.SERVICE__NAME:
				return getName();
			case ISMStatikPackage.SERVICE__INTERFACE:
				if (resolve)
					return getInterface();
				return basicGetInterface();
			case ISMStatikPackage.SERVICE__PROTOCOL:
				return getProtocol();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ISMStatikPackage.SERVICE__NAME:
				setName((String) newValue);
				return;
			case ISMStatikPackage.SERVICE__INTERFACE:
				setInterface((InterfaceType) newValue);
				return;
			case ISMStatikPackage.SERVICE__PROTOCOL:
				setProtocol((ServiceProtocol) newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ISMStatikPackage.SERVICE__NAME:
				setName(NAME_EDEFAULT);
				return;
			case ISMStatikPackage.SERVICE__INTERFACE:
				setInterface((InterfaceType) null);
				return;
			case ISMStatikPackage.SERVICE__PROTOCOL:
				setProtocol((ServiceProtocol) null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ISMStatikPackage.SERVICE__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case ISMStatikPackage.SERVICE__INTERFACE:
				return interface_ != null;
			case ISMStatikPackage.SERVICE__PROTOCOL:
				return protocol != null;
		}
		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(')');
		return result.toString();
	}

} // PartnerPointImpl
