/**
 * generated by Xtext 2.9.2
 */
package org.xtuml.bp.xtext.masl.masl.structure.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.xtuml.bp.xtext.masl.masl.structure.StateDeclaration;
import org.xtuml.bp.xtext.masl.masl.structure.StructurePackage;
import org.xtuml.bp.xtext.masl.masl.structure.TransitionOption;
import org.xtuml.bp.xtext.masl.masl.structure.TransitionRow;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Transition Row</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.xtuml.bp.xtext.masl.masl.structure.impl.TransitionRowImpl#getStart <em>Start</em>}</li>
 *   <li>{@link org.xtuml.bp.xtext.masl.masl.structure.impl.TransitionRowImpl#isNonExistant <em>Non Existant</em>}</li>
 *   <li>{@link org.xtuml.bp.xtext.masl.masl.structure.impl.TransitionRowImpl#getOptions <em>Options</em>}</li>
 * </ul>
 *
 * @generated
 */
public class TransitionRowImpl extends PragmatizedImpl implements TransitionRow {
	/**
	 * The cached value of the '{@link #getStart() <em>Start</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStart()
	 * @generated
	 * @ordered
	 */
	protected StateDeclaration start;

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

	/**
	 * The cached value of the '{@link #isNonExistant() <em>Non Existant</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isNonExistant()
	 * @generated
	 * @ordered
	 */
	protected boolean nonExistant = NON_EXISTANT_EDEFAULT;

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

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public StateDeclaration getStart() {
		if (start != null && start.eIsProxy()) {
			InternalEObject oldStart = (InternalEObject)start;
			start = (StateDeclaration)eResolveProxy(oldStart);
			if (start != oldStart) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, StructurePackage.TRANSITION_ROW__START, oldStart, start));
			}
		}
		return start;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public StateDeclaration basicGetStart() {
		return start;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStart(StateDeclaration newStart) {
		StateDeclaration oldStart = start;
		start = newStart;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StructurePackage.TRANSITION_ROW__START, oldStart, start));
	}

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNonExistant(boolean newNonExistant) {
		boolean oldNonExistant = nonExistant;
		nonExistant = newNonExistant;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StructurePackage.TRANSITION_ROW__NON_EXISTANT, oldNonExistant, nonExistant));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<TransitionOption> getOptions() {
		if (options == null) {
			options = new EObjectContainmentEList<TransitionOption>(TransitionOption.class, this, StructurePackage.TRANSITION_ROW__OPTIONS);
		}
		return options;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case StructurePackage.TRANSITION_ROW__OPTIONS:
				return ((InternalEList<?>)getOptions()).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 StructurePackage.TRANSITION_ROW__START:
				if (resolve) return getStart();
				return basicGetStart();
			case StructurePackage.TRANSITION_ROW__NON_EXISTANT:
				return isNonExistant();
			case StructurePackage.TRANSITION_ROW__OPTIONS:
				return getOptions();
		}
		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 StructurePackage.TRANSITION_ROW__START:
				setStart((StateDeclaration)newValue);
				return;
			case StructurePackage.TRANSITION_ROW__NON_EXISTANT:
				setNonExistant((Boolean)newValue);
				return;
			case StructurePackage.TRANSITION_ROW__OPTIONS:
				getOptions().clear();
				getOptions().addAll((Collection<? extends TransitionOption>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case StructurePackage.TRANSITION_ROW__START:
				setStart((StateDeclaration)null);
				return;
			case StructurePackage.TRANSITION_ROW__NON_EXISTANT:
				setNonExistant(NON_EXISTANT_EDEFAULT);
				return;
			case StructurePackage.TRANSITION_ROW__OPTIONS:
				getOptions().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case StructurePackage.TRANSITION_ROW__START:
				return start != null;
			case StructurePackage.TRANSITION_ROW__NON_EXISTANT:
				return nonExistant != NON_EXISTANT_EDEFAULT;
			case StructurePackage.TRANSITION_ROW__OPTIONS:
				return options != null && !options.isEmpty();
		}
		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(" (nonExistant: ");
		result.append(nonExistant);
		result.append(')');
		return result.toString();
	}

} //TransitionRowImpl
