/**
 */
package org.etsi.mts.tdl.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.DataUse;
import org.etsi.mts.tdl.Member;
import org.etsi.mts.tdl.MemberAssignment;
import org.etsi.mts.tdl.tdlPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Member Assignment</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.etsi.mts.tdl.impl.MemberAssignmentImpl#getMember <em>Member</em>}</li>
 *   <li>{@link org.etsi.mts.tdl.impl.MemberAssignmentImpl#getMemberSpec <em>Member Spec</em>}</li>
 * </ul>
 *
 * @generated
 */
public class MemberAssignmentImpl extends ElementImpl implements MemberAssignment
{
	/**
	 * The cached value of the '{@link #getMember() <em>Member</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMember()
	 * @generated
	 * @ordered
	 */
	protected Member member;

	/**
	 * The cached value of the '{@link #getMemberSpec() <em>Member Spec</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMemberSpec()
	 * @generated
	 * @ordered
	 */
	protected DataUse memberSpec;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Member getMember()
	{
		if (member != null && member.eIsProxy()) {
			InternalEObject oldMember = (InternalEObject)member;
			member = (Member)eResolveProxy(oldMember);
			if (member != oldMember) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, tdlPackage.MEMBER_ASSIGNMENT__MEMBER, oldMember, member));
			}
		}
		return member;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Member basicGetMember()
	{
		return member;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setMember(Member newMember)
	{
		Member oldMember = member;
		member = newMember;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, tdlPackage.MEMBER_ASSIGNMENT__MEMBER, oldMember, member));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public DataUse getMemberSpec()
	{
		return memberSpec;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetMemberSpec(DataUse newMemberSpec, NotificationChain msgs)
	{
		DataUse oldMemberSpec = memberSpec;
		memberSpec = newMemberSpec;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, tdlPackage.MEMBER_ASSIGNMENT__MEMBER_SPEC, oldMemberSpec, newMemberSpec);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setMemberSpec(DataUse newMemberSpec)
	{
		if (newMemberSpec != memberSpec) {
			NotificationChain msgs = null;
			if (memberSpec != null)
				msgs = ((InternalEObject)memberSpec).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - tdlPackage.MEMBER_ASSIGNMENT__MEMBER_SPEC, null, msgs);
			if (newMemberSpec != null)
				msgs = ((InternalEObject)newMemberSpec).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - tdlPackage.MEMBER_ASSIGNMENT__MEMBER_SPEC, null, msgs);
			msgs = basicSetMemberSpec(newMemberSpec, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, tdlPackage.MEMBER_ASSIGNMENT__MEMBER_SPEC, newMemberSpec, newMemberSpec));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
	{
		switch (featureID) {
			case tdlPackage.MEMBER_ASSIGNMENT__MEMBER_SPEC:
				return basicSetMemberSpec(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 tdlPackage.MEMBER_ASSIGNMENT__MEMBER:
				if (resolve) return getMember();
				return basicGetMember();
			case tdlPackage.MEMBER_ASSIGNMENT__MEMBER_SPEC:
				return getMemberSpec();
		}
		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.MEMBER_ASSIGNMENT__MEMBER:
				setMember((Member)newValue);
				return;
			case tdlPackage.MEMBER_ASSIGNMENT__MEMBER_SPEC:
				setMemberSpec((DataUse)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID)
	{
		switch (featureID) {
			case tdlPackage.MEMBER_ASSIGNMENT__MEMBER:
				setMember((Member)null);
				return;
			case tdlPackage.MEMBER_ASSIGNMENT__MEMBER_SPEC:
				setMemberSpec((DataUse)null);
				return;
		}
		super.eUnset(featureID);
	}

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

} //MemberAssignmentImpl
