/**
 */
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.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

import ua.ansymo.hintco.Alternative;
import ua.ansymo.hintco.HintcoPackage;
import ua.ansymo.hintco.RootCandidateScenario;
import ua.ansymo.hintco.Scenario;
import ua.ansymo.hintco.UnitInstance;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Root Candidate Scenario</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link ua.ansymo.hintco.impl.RootCandidateScenarioImpl#getWeight <em>Weight</em>}</li>
 *   <li>{@link ua.ansymo.hintco.impl.RootCandidateScenarioImpl#isSelected <em>Selected</em>}</li>
 *   <li>{@link ua.ansymo.hintco.impl.RootCandidateScenarioImpl#getImplies <em>Implies</em>}</li>
 *   <li>{@link ua.ansymo.hintco.impl.RootCandidateScenarioImpl#getCosimunits <em>Cosimunits</em>}</li>
 *   <li>{@link ua.ansymo.hintco.impl.RootCandidateScenarioImpl#getName <em>Name</em>}</li>
 *   <li>{@link ua.ansymo.hintco.impl.RootCandidateScenarioImpl#getStopTime <em>Stop Time</em>}</li>
 *   <li>{@link ua.ansymo.hintco.impl.RootCandidateScenarioImpl#getStepSize <em>Step Size</em>}</li>
 *   <li>{@link ua.ansymo.hintco.impl.RootCandidateScenarioImpl#getOutputStepSize <em>Output Step Size</em>}</li>
 *   <li>{@link ua.ansymo.hintco.impl.RootCandidateScenarioImpl#getMaxInitIterations <em>Max Init Iterations</em>}</li>
 * </ul>
 *
 * @generated
 */
public class RootCandidateScenarioImpl extends IDedImpl implements RootCandidateScenario {
	/**
	 * The default value of the '{@link #getWeight() <em>Weight</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getWeight()
	 * @generated
	 * @ordered
	 */
	protected static final int WEIGHT_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getWeight() <em>Weight</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getWeight()
	 * @generated
	 * @ordered
	 */
	protected int weight = WEIGHT_EDEFAULT;

	/**
	 * The default value of the '{@link #isSelected() <em>Selected</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isSelected()
	 * @generated
	 * @ordered
	 */
	protected static final boolean SELECTED_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isSelected() <em>Selected</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isSelected()
	 * @generated
	 * @ordered
	 */
	protected boolean selected = SELECTED_EDEFAULT;

	/**
	 * The cached value of the '{@link #getImplies() <em>Implies</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getImplies()
	 * @generated
	 * @ordered
	 */
	protected EList<Alternative> implies;

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

	/**
	 * 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 default value of the '{@link #getStopTime() <em>Stop Time</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStopTime()
	 * @generated
	 * @ordered
	 */
	protected static final double STOP_TIME_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getStopTime() <em>Stop Time</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStopTime()
	 * @generated
	 * @ordered
	 */
	protected double stopTime = STOP_TIME_EDEFAULT;

	/**
	 * The default value of the '{@link #getStepSize() <em>Step Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStepSize()
	 * @generated
	 * @ordered
	 */
	protected static final double STEP_SIZE_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getStepSize() <em>Step Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStepSize()
	 * @generated
	 * @ordered
	 */
	protected double stepSize = STEP_SIZE_EDEFAULT;

	/**
	 * The default value of the '{@link #getOutputStepSize() <em>Output Step Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOutputStepSize()
	 * @generated
	 * @ordered
	 */
	protected static final double OUTPUT_STEP_SIZE_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getOutputStepSize() <em>Output Step Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOutputStepSize()
	 * @generated
	 * @ordered
	 */
	protected double outputStepSize = OUTPUT_STEP_SIZE_EDEFAULT;

	/**
	 * The default value of the '{@link #getMaxInitIterations() <em>Max Init Iterations</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMaxInitIterations()
	 * @generated
	 * @ordered
	 */
	protected static final int MAX_INIT_ITERATIONS_EDEFAULT = 10;

	/**
	 * The cached value of the '{@link #getMaxInitIterations() <em>Max Init Iterations</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMaxInitIterations()
	 * @generated
	 * @ordered
	 */
	protected int maxInitIterations = MAX_INIT_ITERATIONS_EDEFAULT;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getWeight() {
		return weight;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setWeight(int newWeight) {
		int oldWeight = weight;
		weight = newWeight;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, HintcoPackage.ROOT_CANDIDATE_SCENARIO__WEIGHT, oldWeight, weight));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSelected() {
		return selected;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSelected(boolean newSelected) {
		boolean oldSelected = selected;
		selected = newSelected;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, HintcoPackage.ROOT_CANDIDATE_SCENARIO__SELECTED, oldSelected, selected));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Alternative> getImplies() {
		if (implies == null) {
			implies = new EObjectResolvingEList<Alternative>(Alternative.class, this, HintcoPackage.ROOT_CANDIDATE_SCENARIO__IMPLIES);
		}
		return implies;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<UnitInstance> getCosimunits() {
		if (cosimunits == null) {
			cosimunits = new EObjectContainmentWithInverseEList<UnitInstance>(UnitInstance.class, this, HintcoPackage.ROOT_CANDIDATE_SCENARIO__COSIMUNITS, HintcoPackage.UNIT_INSTANCE__SCENARIO);
		}
		return cosimunits;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		String _identifier = this.getIdentifier();
		String _plus = (_identifier + "(w=");
		int _weight = this.getWeight();
		String _plus_1 = (_plus + Integer.valueOf(_weight));
		return (_plus_1 + ")");
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getStopTime() {
		return stopTime;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStopTime(double newStopTime) {
		double oldStopTime = stopTime;
		stopTime = newStopTime;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, HintcoPackage.ROOT_CANDIDATE_SCENARIO__STOP_TIME, oldStopTime, stopTime));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getStepSize() {
		return stepSize;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStepSize(double newStepSize) {
		double oldStepSize = stepSize;
		stepSize = newStepSize;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, HintcoPackage.ROOT_CANDIDATE_SCENARIO__STEP_SIZE, oldStepSize, stepSize));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getOutputStepSize() {
		return outputStepSize;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOutputStepSize(double newOutputStepSize) {
		double oldOutputStepSize = outputStepSize;
		outputStepSize = newOutputStepSize;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, HintcoPackage.ROOT_CANDIDATE_SCENARIO__OUTPUT_STEP_SIZE, oldOutputStepSize, outputStepSize));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getMaxInitIterations() {
		return maxInitIterations;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMaxInitIterations(int newMaxInitIterations) {
		int oldMaxInitIterations = maxInitIterations;
		maxInitIterations = newMaxInitIterations;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, HintcoPackage.ROOT_CANDIDATE_SCENARIO__MAX_INIT_ITERATIONS, oldMaxInitIterations, maxInitIterations));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__COSIMUNITS:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getCosimunits()).basicAdd(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 HintcoPackage.ROOT_CANDIDATE_SCENARIO__COSIMUNITS:
				return ((InternalEList<?>)getCosimunits()).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.ROOT_CANDIDATE_SCENARIO__WEIGHT:
				return getWeight();
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__SELECTED:
				return isSelected();
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__IMPLIES:
				return getImplies();
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__COSIMUNITS:
				return getCosimunits();
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__NAME:
				return getName();
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__STOP_TIME:
				return getStopTime();
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__STEP_SIZE:
				return getStepSize();
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__OUTPUT_STEP_SIZE:
				return getOutputStepSize();
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__MAX_INIT_ITERATIONS:
				return getMaxInitIterations();
		}
		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.ROOT_CANDIDATE_SCENARIO__WEIGHT:
				setWeight((Integer)newValue);
				return;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__SELECTED:
				setSelected((Boolean)newValue);
				return;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__IMPLIES:
				getImplies().clear();
				getImplies().addAll((Collection<? extends Alternative>)newValue);
				return;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__COSIMUNITS:
				getCosimunits().clear();
				getCosimunits().addAll((Collection<? extends UnitInstance>)newValue);
				return;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__STOP_TIME:
				setStopTime((Double)newValue);
				return;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__STEP_SIZE:
				setStepSize((Double)newValue);
				return;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__OUTPUT_STEP_SIZE:
				setOutputStepSize((Double)newValue);
				return;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__MAX_INIT_ITERATIONS:
				setMaxInitIterations((Integer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__WEIGHT:
				setWeight(WEIGHT_EDEFAULT);
				return;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__SELECTED:
				setSelected(SELECTED_EDEFAULT);
				return;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__IMPLIES:
				getImplies().clear();
				return;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__COSIMUNITS:
				getCosimunits().clear();
				return;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__STOP_TIME:
				setStopTime(STOP_TIME_EDEFAULT);
				return;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__STEP_SIZE:
				setStepSize(STEP_SIZE_EDEFAULT);
				return;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__OUTPUT_STEP_SIZE:
				setOutputStepSize(OUTPUT_STEP_SIZE_EDEFAULT);
				return;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__MAX_INIT_ITERATIONS:
				setMaxInitIterations(MAX_INIT_ITERATIONS_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__WEIGHT:
				return weight != WEIGHT_EDEFAULT;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__SELECTED:
				return selected != SELECTED_EDEFAULT;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__IMPLIES:
				return implies != null && !implies.isEmpty();
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__COSIMUNITS:
				return cosimunits != null && !cosimunits.isEmpty();
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__NAME:
				return NAME_EDEFAULT == null ? getName() != null : !NAME_EDEFAULT.equals(getName());
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__STOP_TIME:
				return stopTime != STOP_TIME_EDEFAULT;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__STEP_SIZE:
				return stepSize != STEP_SIZE_EDEFAULT;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__OUTPUT_STEP_SIZE:
				return outputStepSize != OUTPUT_STEP_SIZE_EDEFAULT;
			case HintcoPackage.ROOT_CANDIDATE_SCENARIO__MAX_INIT_ITERATIONS:
				return maxInitIterations != MAX_INIT_ITERATIONS_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
		if (baseClass == Alternative.class) {
			switch (derivedFeatureID) {
				case HintcoPackage.ROOT_CANDIDATE_SCENARIO__WEIGHT: return HintcoPackage.ALTERNATIVE__WEIGHT;
				case HintcoPackage.ROOT_CANDIDATE_SCENARIO__SELECTED: return HintcoPackage.ALTERNATIVE__SELECTED;
				case HintcoPackage.ROOT_CANDIDATE_SCENARIO__IMPLIES: return HintcoPackage.ALTERNATIVE__IMPLIES;
				default: return -1;
			}
		}
		if (baseClass == Scenario.class) {
			switch (derivedFeatureID) {
				case HintcoPackage.ROOT_CANDIDATE_SCENARIO__COSIMUNITS: return HintcoPackage.SCENARIO__COSIMUNITS;
				default: return -1;
			}
		}
		return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) {
		if (baseClass == Alternative.class) {
			switch (baseFeatureID) {
				case HintcoPackage.ALTERNATIVE__WEIGHT: return HintcoPackage.ROOT_CANDIDATE_SCENARIO__WEIGHT;
				case HintcoPackage.ALTERNATIVE__SELECTED: return HintcoPackage.ROOT_CANDIDATE_SCENARIO__SELECTED;
				case HintcoPackage.ALTERNATIVE__IMPLIES: return HintcoPackage.ROOT_CANDIDATE_SCENARIO__IMPLIES;
				default: return -1;
			}
		}
		if (baseClass == Scenario.class) {
			switch (baseFeatureID) {
				case HintcoPackage.SCENARIO__COSIMUNITS: return HintcoPackage.ROOT_CANDIDATE_SCENARIO__COSIMUNITS;
				default: return -1;
			}
		}
		return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
	}

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

		StringBuilder result = new StringBuilder(super.toString());
		result.append(" (weight: ");
		result.append(weight);
		result.append(", selected: ");
		result.append(selected);
		result.append(", stopTime: ");
		result.append(stopTime);
		result.append(", stepSize: ");
		result.append(stepSize);
		result.append(", outputStepSize: ");
		result.append(outputStepSize);
		result.append(", maxInitIterations: ");
		result.append(maxInitIterations);
		result.append(')');
		return result.toString();
	}

} //RootCandidateScenarioImpl
