public abstract class StateMachine.Transition
extends java.lang.Object
Represents: transition
Usage:
Define subclasses of this class as inner classes of a subclass of
StateMachine
or CompositeState
. These
subclasses will represent the transitions of those state machines or
composite states.
A transition must have a From
and a To
annotation to
specify its source and target vertices. A Trigger
annotation has
to be applied if the transition is from a state or composite state and
might not be applied if it is from a pseudostate (initial or choice).
A transition must connect two vertices that are on the same level of the
hierarchical state machine, that is, their representing classes are the
inner classes of the same StateMachine
or
CompositeState
subclass as the transition itself.
An effect()
of the transition might be defined which is executed
when the state machine uses that transition. Its guard()
is
evaluated each time the state machine tries to use the transition, and
only uses it if the guard
is evaluated to true
.
See the documentation of those methods for details.
Java restrictions:
Subtype requirements:
StateMachine
or
StateMachine.CompositeState
Subtype restrictions:
See the documentation of StateMachine
for detailed examples.
See the documentation of Model
for an overview on modeling in
JtxtUML.
Constructor and Description |
---|
Transition() |
Modifier and Type | Method and Description |
---|---|
void |
effect()
Overridable method to implement the effect of this transition.
|
protected static boolean |
Else()
In the
guard s of transitions which are from
StateMachine.Choice pseudostates, else conditions might be given,
for the corresponding transitions to be used when all other
potentially usable transitions' guards are evaluated to true. |
protected <T extends Signal> |
getTrigger(java.lang.Class<T> signalClass)
Returns the signal receiving which triggered the execution (or the
call of the guard) of this transition.
|
boolean |
guard()
Overridable method to implement the guard of this transition.
|
java.lang.String |
toString() |
public void effect()
Called when this transition is chosen for execution, after calling all exit actions from left vertices and before calling any entry actions.
If the actual transition has a trigger defined, the
getTrigger
method can be used inside the overriding methods
to get the triggering signal.
Overriding methods may only contain action code. See the
documentation of Model
for details about the action language.
public boolean guard()
Might not be overridden in transition classes that are from initial pseudostates.
If overridden, the return value must never be null
.
If the overriding method returns false
, this
transition will not be chosen to be executed.
If the overriding method returns true
, this
transition might be chosen to be executed. Only one such transition
may exist at any time (for which the two conditions mentioned above,
regarding the source vertex and the triggering signal, are also met).
Two such transitions are allowed to exist in one special case:
guard
method returns an
Else()
condition,guard
method does not return
an Else()
condition.In this case, the second transition will be executed as the one with an else condition is executed only if no other transition might be used.
If the overriding method once returns an Else()
condition, it
should always do so.
If the actual transition has a trigger defined, the
getTrigger
method can be used inside the overriding methods
to get the triggering signal.
Overriding methods may only contain a condition evaluation. See the
documentation of Model
for details about condition
evaluations in the model.
true
by default implementation@ExternalBody protected final <T extends Signal> T getTrigger(java.lang.Class<T> signalClass) throws java.lang.ClassCastException
Signal
.
It is guaranteed for this method to return a non-null value successfully if the following conditions are met for the actual transition t and a signal s:
Trigger
annotation defined which's value
is set to s or any of its supertypes, orT
- the type to which the casting should be performedsignalClass
- the signal class to which the casting should be performedjava.lang.ClassCastException
- if the cast might not be performed@ExternalBody public java.lang.String toString()
toString
in class java.lang.Object
@ExternalBody protected static boolean Else() throws ElseException
guard
s of transitions which are from
StateMachine.Choice
pseudostates, else conditions might be given,
for the corresponding transitions to be used when all other
potentially usable transitions' guards are evaluated to true.
To define an else condition, simply override the
guard
of a transition to return with the
value returned by this method:
@Override
public boolean guard() {
return Else();
}
For the sake of the implementation, this method in fact returns
nothing but throws a special exception instead, which might be caught
then by the API. Therefore, it is important that this method is only
called in an overridden guard
method when the actual
transition is from a choice pseudostate.ElseException
- always, due to implementation issues; should not be
caught by user codeguard()