/** */ package fsm.impl; import fsm.FsmPackage; import fsm.State; import fsm.Transition; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; 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.EcoreUtil; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Transition</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link fsm.impl.TransitionImpl#getSource <em>Source</em>}</li> * <li>{@link fsm.impl.TransitionImpl#getTarget <em>Target</em>}</li> * <li>{@link fsm.impl.TransitionImpl#getInput <em>Input</em>}</li> * <li>{@link fsm.impl.TransitionImpl#getOutput <em>Output</em>}</li> * </ul> * </p> * * @generated */ public class TransitionImpl extends MinimalEObjectImpl.Container implements Transition { /** * The cached value of the '{@link #getTarget() <em>Target</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getTarget() * @generated * @ordered */ protected State target; /** * The default value of the '{@link #getInput() <em>Input</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getInput() * @generated * @ordered */ protected static final String INPUT_EDEFAULT = null; /** * The cached value of the '{@link #getInput() <em>Input</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getInput() * @generated * @ordered */ protected String input = INPUT_EDEFAULT; /** * The default value of the '{@link #getOutput() <em>Output</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getOutput() * @generated * @ordered */ protected static final String OUTPUT_EDEFAULT = null; /** * The cached value of the '{@link #getOutput() <em>Output</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getOutput() * @generated * @ordered */ protected String output = OUTPUT_EDEFAULT; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected TransitionImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return FsmPackage.Literals.TRANSITION; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public State getSource() { if (eContainerFeatureID() != FsmPackage.TRANSITION__SOURCE) return null; return (State)eInternalContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetSource(State newSource, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject)newSource, FsmPackage.TRANSITION__SOURCE, msgs); return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setSource(State newSource) { if (newSource != eInternalContainer() || (eContainerFeatureID() != FsmPackage.TRANSITION__SOURCE && newSource != null)) { if (EcoreUtil.isAncestor(this, newSource)) throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newSource != null) msgs = ((InternalEObject)newSource).eInverseAdd(this, FsmPackage.STATE__OUTGOING_TRANSITION, State.class, msgs); msgs = basicSetSource(newSource, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, FsmPackage.TRANSITION__SOURCE, newSource, newSource)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public State getTarget() { if (target != null && target.eIsProxy()) { InternalEObject oldTarget = (InternalEObject)target; target = (State)eResolveProxy(oldTarget); if (target != oldTarget) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, FsmPackage.TRANSITION__TARGET, oldTarget, target)); } } return target; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public State basicGetTarget() { return target; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetTarget(State newTarget, NotificationChain msgs) { State oldTarget = target; target = newTarget; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, FsmPackage.TRANSITION__TARGET, oldTarget, newTarget); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setTarget(State newTarget) { if (newTarget != target) { NotificationChain msgs = null; if (target != null) msgs = ((InternalEObject)target).eInverseRemove(this, FsmPackage.STATE__INCOMING_TRANSITION, State.class, msgs); if (newTarget != null) msgs = ((InternalEObject)newTarget).eInverseAdd(this, FsmPackage.STATE__INCOMING_TRANSITION, State.class, msgs); msgs = basicSetTarget(newTarget, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, FsmPackage.TRANSITION__TARGET, newTarget, newTarget)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getInput() { return input; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setInput(String newInput) { String oldInput = input; input = newInput; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, FsmPackage.TRANSITION__INPUT, oldInput, input)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getOutput() { return output; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setOutput(String newOutput) { String oldOutput = output; output = newOutput; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, FsmPackage.TRANSITION__OUTPUT, oldOutput, output)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case FsmPackage.TRANSITION__SOURCE: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetSource((State)otherEnd, msgs); case FsmPackage.TRANSITION__TARGET: if (target != null) msgs = ((InternalEObject)target).eInverseRemove(this, FsmPackage.STATE__INCOMING_TRANSITION, State.class, msgs); return basicSetTarget((State)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 FsmPackage.TRANSITION__SOURCE: return basicSetSource(null, msgs); case FsmPackage.TRANSITION__TARGET: return basicSetTarget(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID()) { case FsmPackage.TRANSITION__SOURCE: return eInternalContainer().eInverseRemove(this, FsmPackage.STATE__OUTGOING_TRANSITION, State.class, msgs); } return super.eBasicRemoveFromContainerFeature(msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case FsmPackage.TRANSITION__SOURCE: return getSource(); case FsmPackage.TRANSITION__TARGET: if (resolve) return getTarget(); return basicGetTarget(); case FsmPackage.TRANSITION__INPUT: return getInput(); case FsmPackage.TRANSITION__OUTPUT: return getOutput(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case FsmPackage.TRANSITION__SOURCE: setSource((State)newValue); return; case FsmPackage.TRANSITION__TARGET: setTarget((State)newValue); return; case FsmPackage.TRANSITION__INPUT: setInput((String)newValue); return; case FsmPackage.TRANSITION__OUTPUT: setOutput((String)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case FsmPackage.TRANSITION__SOURCE: setSource((State)null); return; case FsmPackage.TRANSITION__TARGET: setTarget((State)null); return; case FsmPackage.TRANSITION__INPUT: setInput(INPUT_EDEFAULT); return; case FsmPackage.TRANSITION__OUTPUT: setOutput(OUTPUT_EDEFAULT); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case FsmPackage.TRANSITION__SOURCE: return getSource() != null; case FsmPackage.TRANSITION__TARGET: return target != null; case FsmPackage.TRANSITION__INPUT: return INPUT_EDEFAULT == null ? input != null : !INPUT_EDEFAULT.equals(input); case FsmPackage.TRANSITION__OUTPUT: return OUTPUT_EDEFAULT == null ? output != null : !OUTPUT_EDEFAULT.equals(output); } 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(" (input: "); result.append(input); result.append(", output: "); result.append(output); result.append(')'); return result.toString(); } } //TransitionImpl