/**
*/
package fr.inria.diverse.minifsm.impl;
import fr.inria.diverse.minifsm.FSM;
import fr.inria.diverse.minifsm.MinifsmPackage;
import fr.inria.diverse.minifsm.State;
import fr.inria.diverse.minifsm.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:
* </p>
* <ul>
* <li>{@link fr.inria.diverse.minifsm.impl.TransitionImpl#getInput <em>Input</em>}</li>
* <li>{@link fr.inria.diverse.minifsm.impl.TransitionImpl#getOutput <em>Output</em>}</li>
* <li>{@link fr.inria.diverse.minifsm.impl.TransitionImpl#getFsm <em>Fsm</em>}</li>
* <li>{@link fr.inria.diverse.minifsm.impl.TransitionImpl#getEvent <em>Event</em>}</li>
* </ul>
*
* @generated
*/
public class TransitionImpl extends MinimalEObjectImpl.Container implements Transition {
/**
* The cached value of the '{@link #getInput() <em>Input</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getInput()
* @generated
* @ordered
*/
protected State input;
/**
* The cached value of the '{@link #getOutput() <em>Output</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOutput()
* @generated
* @ordered
*/
protected State output;
/**
* The default value of the '{@link #getEvent() <em>Event</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getEvent()
* @generated
* @ordered
*/
protected static final String EVENT_EDEFAULT = null;
/**
* The cached value of the '{@link #getEvent() <em>Event</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getEvent()
* @generated
* @ordered
*/
protected String event = EVENT_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected TransitionImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return MinifsmPackage.Literals.TRANSITION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public State getInput() {
if (input != null && input.eIsProxy()) {
InternalEObject oldInput = (InternalEObject)input;
input = (State)eResolveProxy(oldInput);
if (input != oldInput) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, MinifsmPackage.TRANSITION__INPUT, oldInput, input));
}
}
return input;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public State basicGetInput() {
return input;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setInput(State newInput) {
State oldInput = input;
input = newInput;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MinifsmPackage.TRANSITION__INPUT, oldInput, input));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public State getOutput() {
if (output != null && output.eIsProxy()) {
InternalEObject oldOutput = (InternalEObject)output;
output = (State)eResolveProxy(oldOutput);
if (output != oldOutput) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, MinifsmPackage.TRANSITION__OUTPUT, oldOutput, output));
}
}
return output;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public State basicGetOutput() {
return output;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOutput(State newOutput) {
State oldOutput = output;
output = newOutput;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MinifsmPackage.TRANSITION__OUTPUT, oldOutput, output));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public FSM getFsm() {
if (eContainerFeatureID() != MinifsmPackage.TRANSITION__FSM) return null;
return (FSM)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetFsm(FSM newFsm, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newFsm, MinifsmPackage.TRANSITION__FSM, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setFsm(FSM newFsm) {
if (newFsm != eInternalContainer() || (eContainerFeatureID() != MinifsmPackage.TRANSITION__FSM && newFsm != null)) {
if (EcoreUtil.isAncestor(this, newFsm))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newFsm != null)
msgs = ((InternalEObject)newFsm).eInverseAdd(this, MinifsmPackage.FSM__TRANSITIONS, FSM.class, msgs);
msgs = basicSetFsm(newFsm, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MinifsmPackage.TRANSITION__FSM, newFsm, newFsm));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getEvent() {
return event;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setEvent(String newEvent) {
String oldEvent = event;
event = newEvent;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MinifsmPackage.TRANSITION__EVENT, oldEvent, event));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case MinifsmPackage.TRANSITION__FSM:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetFsm((FSM)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 MinifsmPackage.TRANSITION__FSM:
return basicSetFsm(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case MinifsmPackage.TRANSITION__FSM:
return eInternalContainer().eInverseRemove(this, MinifsmPackage.FSM__TRANSITIONS, FSM.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 MinifsmPackage.TRANSITION__INPUT:
if (resolve) return getInput();
return basicGetInput();
case MinifsmPackage.TRANSITION__OUTPUT:
if (resolve) return getOutput();
return basicGetOutput();
case MinifsmPackage.TRANSITION__FSM:
return getFsm();
case MinifsmPackage.TRANSITION__EVENT:
return getEvent();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case MinifsmPackage.TRANSITION__INPUT:
setInput((State)newValue);
return;
case MinifsmPackage.TRANSITION__OUTPUT:
setOutput((State)newValue);
return;
case MinifsmPackage.TRANSITION__FSM:
setFsm((FSM)newValue);
return;
case MinifsmPackage.TRANSITION__EVENT:
setEvent((String)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case MinifsmPackage.TRANSITION__INPUT:
setInput((State)null);
return;
case MinifsmPackage.TRANSITION__OUTPUT:
setOutput((State)null);
return;
case MinifsmPackage.TRANSITION__FSM:
setFsm((FSM)null);
return;
case MinifsmPackage.TRANSITION__EVENT:
setEvent(EVENT_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case MinifsmPackage.TRANSITION__INPUT:
return input != null;
case MinifsmPackage.TRANSITION__OUTPUT:
return output != null;
case MinifsmPackage.TRANSITION__FSM:
return getFsm() != null;
case MinifsmPackage.TRANSITION__EVENT:
return EVENT_EDEFAULT == null ? event != null : !EVENT_EDEFAULT.equals(event);
}
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(" (event: ");
result.append(event);
result.append(')');
return result.toString();
}
} //TransitionImpl