/** */ package simplefsm.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.EObjectContainmentWithInverseEList; import org.eclipse.emf.ecore.util.InternalEList; import simplefsm.FSM; import simplefsm.SimplefsmPackage; import simplefsm.State; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>FSM</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link simplefsm.impl.FSMImpl#getOwnedState <em>Owned State</em>}</li> * <li>{@link simplefsm.impl.FSMImpl#getInitialState <em>Initial State</em>}</li> * </ul> * </p> * * @generated */ public class FSMImpl extends MinimalEObjectImpl.Container implements FSM { /** * The cached value of the '{@link #getOwnedState() <em>Owned State</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getOwnedState() * @generated * @ordered */ protected EList<State> ownedState; /** * The cached value of the '{@link #getInitialState() <em>Initial State</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getInitialState() * @generated * @ordered */ protected State initialState; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected FSMImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return SimplefsmPackage.Literals.FSM; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<State> getOwnedState() { if (ownedState == null) { ownedState = new EObjectContainmentWithInverseEList<State>(State.class, this, SimplefsmPackage.FSM__OWNED_STATE, SimplefsmPackage.STATE__OWNING_FSM); } return ownedState; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public State getInitialState() { if (initialState != null && initialState.eIsProxy()) { InternalEObject oldInitialState = (InternalEObject)initialState; initialState = (State)eResolveProxy(oldInitialState); if (initialState != oldInitialState) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, SimplefsmPackage.FSM__INITIAL_STATE, oldInitialState, initialState)); } } return initialState; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public State basicGetInitialState() { return initialState; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setInitialState(State newInitialState) { State oldInitialState = initialState; initialState = newInitialState; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, SimplefsmPackage.FSM__INITIAL_STATE, oldInitialState, initialState)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case SimplefsmPackage.FSM__OWNED_STATE: return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedState()).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 SimplefsmPackage.FSM__OWNED_STATE: return ((InternalEList<?>)getOwnedState()).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 SimplefsmPackage.FSM__OWNED_STATE: return getOwnedState(); case SimplefsmPackage.FSM__INITIAL_STATE: if (resolve) return getInitialState(); return basicGetInitialState(); } 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 SimplefsmPackage.FSM__OWNED_STATE: getOwnedState().clear(); getOwnedState().addAll((Collection<? extends State>)newValue); return; case SimplefsmPackage.FSM__INITIAL_STATE: setInitialState((State)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case SimplefsmPackage.FSM__OWNED_STATE: getOwnedState().clear(); return; case SimplefsmPackage.FSM__INITIAL_STATE: setInitialState((State)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case SimplefsmPackage.FSM__OWNED_STATE: return ownedState != null && !ownedState.isEmpty(); case SimplefsmPackage.FSM__INITIAL_STATE: return initialState != null; } return super.eIsSet(featureID); } } //FSMImpl