/** | |
* <copyright> | |
* </copyright> | |
* | |
* $Id$ | |
*/ | |
package statemachine.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.EObjectImpl; | |
import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; | |
import org.eclipse.emf.ecore.util.EcoreUtil; | |
import statemachine.State; | |
import statemachine.StatemachinePackage; | |
import statemachine.Transition; | |
/** | |
* <!-- 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 statemachine.impl.TransitionImpl#getSource <em>Source</em>}</li> | |
* <li>{@link statemachine.impl.TransitionImpl#getTarget <em>Target</em>}</li> | |
* <li>{@link statemachine.impl.TransitionImpl#getTrigger <em>Trigger</em>}</li> | |
* <li>{@link statemachine.impl.TransitionImpl#getEffect <em>Effect</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class TransitionImpl extends EObjectImpl 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 #getTrigger() <em>Trigger</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getTrigger() | |
* @generated | |
* @ordered | |
*/ | |
protected static final String TRIGGER_EDEFAULT = null; | |
/** | |
* The cached value of the '{@link #getTrigger() <em>Trigger</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getTrigger() | |
* @generated | |
* @ordered | |
*/ | |
protected String trigger = TRIGGER_EDEFAULT; | |
/** | |
* The cached value of the '{@link #getEffect() <em>Effect</em>}' attribute list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getEffect() | |
* @generated | |
* @ordered | |
*/ | |
protected EList effect; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected TransitionImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected EClass eStaticClass() { | |
return StatemachinePackage.Literals.TRANSITION; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public State getSource() { | |
if (eContainerFeatureID() != StatemachinePackage.TRANSITION__SOURCE) return null; | |
return (State)eContainer(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetSource(State newSource, NotificationChain msgs) { | |
msgs = eBasicSetContainer((InternalEObject)newSource, StatemachinePackage.TRANSITION__SOURCE, msgs); | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setSource(State newSource) { | |
if (newSource != eInternalContainer() || (eContainerFeatureID() != StatemachinePackage.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, StatemachinePackage.STATE__OUTGOING, State.class, msgs); | |
msgs = basicSetSource(newSource, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, StatemachinePackage.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, StatemachinePackage.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, StatemachinePackage.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, StatemachinePackage.STATE__INCOMING, State.class, msgs); | |
if (newTarget != null) | |
msgs = ((InternalEObject)newTarget).eInverseAdd(this, StatemachinePackage.STATE__INCOMING, State.class, msgs); | |
msgs = basicSetTarget(newTarget, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, StatemachinePackage.TRANSITION__TARGET, newTarget, newTarget)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public String getTrigger() { | |
return trigger; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setTrigger(String newTrigger) { | |
String oldTrigger = trigger; | |
trigger = newTrigger; | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, StatemachinePackage.TRANSITION__TRIGGER, oldTrigger, trigger)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EList getEffect() { | |
if (effect == null) { | |
effect = new EDataTypeUniqueEList(String.class, this, StatemachinePackage.TRANSITION__EFFECT); | |
} | |
return effect; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case StatemachinePackage.TRANSITION__SOURCE: | |
if (eInternalContainer() != null) | |
msgs = eBasicRemoveFromContainer(msgs); | |
return basicSetSource((State)otherEnd, msgs); | |
case StatemachinePackage.TRANSITION__TARGET: | |
if (target != null) | |
msgs = ((InternalEObject)target).eInverseRemove(this, StatemachinePackage.STATE__INCOMING, State.class, msgs); | |
return basicSetTarget((State)otherEnd, msgs); | |
} | |
return super.eInverseAdd(otherEnd, featureID, msgs); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case StatemachinePackage.TRANSITION__SOURCE: | |
return basicSetSource(null, msgs); | |
case StatemachinePackage.TRANSITION__TARGET: | |
return basicSetTarget(null, msgs); | |
} | |
return super.eInverseRemove(otherEnd, featureID, msgs); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { | |
switch (eContainerFeatureID()) { | |
case StatemachinePackage.TRANSITION__SOURCE: | |
return eInternalContainer().eInverseRemove(this, StatemachinePackage.STATE__OUTGOING, State.class, msgs); | |
} | |
return super.eBasicRemoveFromContainerFeature(msgs); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Object eGet(int featureID, boolean resolve, boolean coreType) { | |
switch (featureID) { | |
case StatemachinePackage.TRANSITION__SOURCE: | |
return getSource(); | |
case StatemachinePackage.TRANSITION__TARGET: | |
if (resolve) return getTarget(); | |
return basicGetTarget(); | |
case StatemachinePackage.TRANSITION__TRIGGER: | |
return getTrigger(); | |
case StatemachinePackage.TRANSITION__EFFECT: | |
return getEffect(); | |
} | |
return super.eGet(featureID, resolve, coreType); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void eSet(int featureID, Object newValue) { | |
switch (featureID) { | |
case StatemachinePackage.TRANSITION__SOURCE: | |
setSource((State)newValue); | |
return; | |
case StatemachinePackage.TRANSITION__TARGET: | |
setTarget((State)newValue); | |
return; | |
case StatemachinePackage.TRANSITION__TRIGGER: | |
setTrigger((String)newValue); | |
return; | |
case StatemachinePackage.TRANSITION__EFFECT: | |
getEffect().clear(); | |
getEffect().addAll((Collection)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case StatemachinePackage.TRANSITION__SOURCE: | |
setSource((State)null); | |
return; | |
case StatemachinePackage.TRANSITION__TARGET: | |
setTarget((State)null); | |
return; | |
case StatemachinePackage.TRANSITION__TRIGGER: | |
setTrigger(TRIGGER_EDEFAULT); | |
return; | |
case StatemachinePackage.TRANSITION__EFFECT: | |
getEffect().clear(); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case StatemachinePackage.TRANSITION__SOURCE: | |
return getSource() != null; | |
case StatemachinePackage.TRANSITION__TARGET: | |
return target != null; | |
case StatemachinePackage.TRANSITION__TRIGGER: | |
return TRIGGER_EDEFAULT == null ? trigger != null : !TRIGGER_EDEFAULT.equals(trigger); | |
case StatemachinePackage.TRANSITION__EFFECT: | |
return effect != null && !effect.isEmpty(); | |
} | |
return super.eIsSet(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public String toString() { | |
if (eIsProxy()) return super.toString(); | |
StringBuffer result = new StringBuffer(super.toString()); | |
result.append(" (trigger: "); | |
result.append(trigger); | |
result.append(", effect: "); | |
result.append(effect); | |
result.append(')'); | |
return result.toString(); | |
} | |
} //TransitionImpl |