- java.lang.Object
-
- io.github.interacto.fsm.Transition<E>
-
- Type Parameters:
E- The type of events the FSM processes.
- Direct Known Subclasses:
SubFSMTransition,TimeoutTransition,WidgetTransition
public abstract class Transition<E> extends Object
The base implementation of a FSM transition.
-
-
Field Summary
Fields Modifier and Type Field Description protected OutputState<E>srcprotected InputState<E>tgt
-
Constructor Summary
Constructors Modifier Constructor Description protectedTransition(OutputState<E> srcState, InputState<E> tgtState)Creates the transition.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract booleanaccept(E event)protected voidaction(E event)Optional<InputState<E>>execute(E event)Executes the transition.abstract Set<Object>getAcceptedEvents()protected abstract booleanisGuardOK(E event)voiduninstall()Clean the transition when not used anymore.
-
-
-
Field Detail
-
src
protected final OutputState<E> src
-
tgt
protected final InputState<E> tgt
-
-
Constructor Detail
-
Transition
protected Transition(OutputState<E> srcState, InputState<E> tgtState)
Creates the transition.- Parameters:
srcState- The source state of the transition.tgtState- The output state of the transition.- Throws:
IllegalArgumentException- If one of the states is null.
-
-
Method Detail
-
execute
public Optional<InputState<E>> execute(E event) throws CancelFSMException
Executes the transition.- Parameters:
event- The event to process.- Returns:
- The potential output state.
- Throws:
CancelFSMException- If the execution cancels the FSM execution.
-
action
protected void action(E event)
-
accept
protected abstract boolean accept(E event)
-
isGuardOK
protected abstract boolean isGuardOK(E event)
-
getAcceptedEvents
public abstract Set<Object> getAcceptedEvents()
- Returns:
- The set of events accepted by the transition.
-
uninstall
public void uninstall()
Clean the transition when not used anymore.
-
-