/**
 */
package ua.ansymo.hintco.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.impl.MinimalEObjectImpl;

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

import ua.ansymo.hintco.CandidateScenario;
import ua.ansymo.hintco.Candidates;
import ua.ansymo.hintco.CosimUnitDeclaration;
import ua.ansymo.hintco.HintcoPackage;
import ua.ansymo.hintco.VariantDiagram;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Candidates</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link ua.ansymo.hintco.impl.CandidatesImpl#getCandidates <em>Candidates</em>}</li>
 *   <li>{@link ua.ansymo.hintco.impl.CandidatesImpl#getCsuDeclarations <em>Csu Declarations</em>}</li>
 *   <li>{@link ua.ansymo.hintco.impl.CandidatesImpl#getRoot <em>Root</em>}</li>
 *   <li>{@link ua.ansymo.hintco.impl.CandidatesImpl#getNodes <em>Nodes</em>}</li>
 * </ul>
 *
 * @generated
 */
public class CandidatesImpl extends MinimalEObjectImpl.Container implements Candidates {
	/**
	 * The cached value of the '{@link #getCandidates() <em>Candidates</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCandidates()
	 * @generated
	 * @ordered
	 */
	protected EList<CandidateScenario> candidates;

	/**
	 * The cached value of the '{@link #getCsuDeclarations() <em>Csu Declarations</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCsuDeclarations()
	 * @generated
	 * @ordered
	 */
	protected EList<CosimUnitDeclaration> csuDeclarations;

	/**
	 * The cached value of the '{@link #getRoot() <em>Root</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRoot()
	 * @generated
	 * @ordered
	 */
	protected VariantDiagram root;

	/**
	 * The cached value of the '{@link #getNodes() <em>Nodes</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNodes()
	 * @generated
	 * @ordered
	 */
	protected EList<VariantDiagram> nodes;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<CandidateScenario> getCandidates() {
		if (candidates == null) {
			candidates = new EObjectContainmentEList<CandidateScenario>(CandidateScenario.class, this, HintcoPackage.CANDIDATES__CANDIDATES);
		}
		return candidates;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<CosimUnitDeclaration> getCsuDeclarations() {
		if (csuDeclarations == null) {
			csuDeclarations = new EObjectContainmentEList<CosimUnitDeclaration>(CosimUnitDeclaration.class, this, HintcoPackage.CANDIDATES__CSU_DECLARATIONS);
		}
		return csuDeclarations;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public VariantDiagram getRoot() {
		if (root != null && root.eIsProxy()) {
			InternalEObject oldRoot = (InternalEObject)root;
			root = (VariantDiagram)eResolveProxy(oldRoot);
			if (root != oldRoot) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, HintcoPackage.CANDIDATES__ROOT, oldRoot, root));
			}
		}
		return root;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public VariantDiagram basicGetRoot() {
		return root;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRoot(VariantDiagram newRoot) {
		VariantDiagram oldRoot = root;
		root = newRoot;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, HintcoPackage.CANDIDATES__ROOT, oldRoot, root));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<VariantDiagram> getNodes() {
		if (nodes == null) {
			nodes = new EObjectContainmentEList<VariantDiagram>(VariantDiagram.class, this, HintcoPackage.CANDIDATES__NODES);
		}
		return nodes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case HintcoPackage.CANDIDATES__CANDIDATES:
				return ((InternalEList<?>)getCandidates()).basicRemove(otherEnd, msgs);
			case HintcoPackage.CANDIDATES__CSU_DECLARATIONS:
				return ((InternalEList<?>)getCsuDeclarations()).basicRemove(otherEnd, msgs);
			case HintcoPackage.CANDIDATES__NODES:
				return ((InternalEList<?>)getNodes()).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 HintcoPackage.CANDIDATES__CANDIDATES:
				return getCandidates();
			case HintcoPackage.CANDIDATES__CSU_DECLARATIONS:
				return getCsuDeclarations();
			case HintcoPackage.CANDIDATES__ROOT:
				if (resolve) return getRoot();
				return basicGetRoot();
			case HintcoPackage.CANDIDATES__NODES:
				return getNodes();
		}
		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 HintcoPackage.CANDIDATES__CANDIDATES:
				getCandidates().clear();
				getCandidates().addAll((Collection<? extends CandidateScenario>)newValue);
				return;
			case HintcoPackage.CANDIDATES__CSU_DECLARATIONS:
				getCsuDeclarations().clear();
				getCsuDeclarations().addAll((Collection<? extends CosimUnitDeclaration>)newValue);
				return;
			case HintcoPackage.CANDIDATES__ROOT:
				setRoot((VariantDiagram)newValue);
				return;
			case HintcoPackage.CANDIDATES__NODES:
				getNodes().clear();
				getNodes().addAll((Collection<? extends VariantDiagram>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case HintcoPackage.CANDIDATES__CANDIDATES:
				getCandidates().clear();
				return;
			case HintcoPackage.CANDIDATES__CSU_DECLARATIONS:
				getCsuDeclarations().clear();
				return;
			case HintcoPackage.CANDIDATES__ROOT:
				setRoot((VariantDiagram)null);
				return;
			case HintcoPackage.CANDIDATES__NODES:
				getNodes().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case HintcoPackage.CANDIDATES__CANDIDATES:
				return candidates != null && !candidates.isEmpty();
			case HintcoPackage.CANDIDATES__CSU_DECLARATIONS:
				return csuDeclarations != null && !csuDeclarations.isEmpty();
			case HintcoPackage.CANDIDATES__ROOT:
				return root != null;
			case HintcoPackage.CANDIDATES__NODES:
				return nodes != null && !nodes.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //CandidatesImpl
