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

import java.util.Collection;

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

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.etsi.mts.tdl.MemberAssignment;
import org.etsi.mts.tdl.StructuredDataInstance;
import org.etsi.mts.tdl.UnassignedMemberTreatment;
import org.etsi.mts.tdl.tdlPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Structured Data Instance</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.etsi.mts.tdl.impl.StructuredDataInstanceImpl#getMemberAssignment <em>Member Assignment</em>}</li>
 *   <li>{@link org.etsi.mts.tdl.impl.StructuredDataInstanceImpl#getUnassignedMember <em>Unassigned Member</em>}</li>
 * </ul>
 *
 * @generated
 */
public class StructuredDataInstanceImpl extends DataInstanceImpl implements StructuredDataInstance
{
	/**
	 * The cached value of the '{@link #getMemberAssignment() <em>Member Assignment</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMemberAssignment()
	 * @generated
	 * @ordered
	 */
	protected EList<MemberAssignment> memberAssignment;

	/**
	 * The default value of the '{@link #getUnassignedMember() <em>Unassigned Member</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUnassignedMember()
	 * @generated
	 * @ordered
	 */
	protected static final UnassignedMemberTreatment UNASSIGNED_MEMBER_EDEFAULT = UnassignedMemberTreatment.UNDEFINED;

	/**
	 * The cached value of the '{@link #getUnassignedMember() <em>Unassigned Member</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUnassignedMember()
	 * @generated
	 * @ordered
	 */
	protected UnassignedMemberTreatment unassignedMember = UNASSIGNED_MEMBER_EDEFAULT;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EList<MemberAssignment> getMemberAssignment()
	{
		if (memberAssignment == null) {
			memberAssignment = new EObjectContainmentEList<MemberAssignment>(MemberAssignment.class, this, tdlPackage.STRUCTURED_DATA_INSTANCE__MEMBER_ASSIGNMENT);
		}
		return memberAssignment;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public UnassignedMemberTreatment getUnassignedMember()
	{
		return unassignedMember;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setUnassignedMember(UnassignedMemberTreatment newUnassignedMember)
	{
		UnassignedMemberTreatment oldUnassignedMember = unassignedMember;
		unassignedMember = newUnassignedMember == null ? UNASSIGNED_MEMBER_EDEFAULT : newUnassignedMember;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, tdlPackage.STRUCTURED_DATA_INSTANCE__UNASSIGNED_MEMBER, oldUnassignedMember, unassignedMember));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
	{
		switch (featureID) {
			case tdlPackage.STRUCTURED_DATA_INSTANCE__MEMBER_ASSIGNMENT:
				return ((InternalEList<?>)getMemberAssignment()).basicRemove(otherEnd, 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.STRUCTURED_DATA_INSTANCE__MEMBER_ASSIGNMENT:
				return getMemberAssignment();
			case tdlPackage.STRUCTURED_DATA_INSTANCE__UNASSIGNED_MEMBER:
				return getUnassignedMember();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue)
	{
		switch (featureID) {
			case tdlPackage.STRUCTURED_DATA_INSTANCE__MEMBER_ASSIGNMENT:
				getMemberAssignment().clear();
				getMemberAssignment().addAll((Collection<? extends MemberAssignment>)newValue);
				return;
			case tdlPackage.STRUCTURED_DATA_INSTANCE__UNASSIGNED_MEMBER:
				setUnassignedMember((UnassignedMemberTreatment)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID)
	{
		switch (featureID) {
			case tdlPackage.STRUCTURED_DATA_INSTANCE__MEMBER_ASSIGNMENT:
				getMemberAssignment().clear();
				return;
			case tdlPackage.STRUCTURED_DATA_INSTANCE__UNASSIGNED_MEMBER:
				setUnassignedMember(UNASSIGNED_MEMBER_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID)
	{
		switch (featureID) {
			case tdlPackage.STRUCTURED_DATA_INSTANCE__MEMBER_ASSIGNMENT:
				return memberAssignment != null && !memberAssignment.isEmpty();
			case tdlPackage.STRUCTURED_DATA_INSTANCE__UNASSIGNED_MEMBER:
				return unassignedMember != UNASSIGNED_MEMBER_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString()
	{
		if (eIsProxy()) return super.toString();

		StringBuilder result = new StringBuilder(super.toString());
		result.append(" (unassignedMember: ");
		result.append(unassignedMember);
		result.append(')');
		return result.toString();
	}

} //StructuredDataInstanceImpl
