- java.lang.Object
-
- io.github.interacto.fsm.Transition<E>
-
- io.github.interacto.fsm.TimeoutTransition<E>
-
- Type Parameters:
E- The type of events the FSM processes.
public class TimeoutTransition<E> extends Transition<E>
A timeout transition is an FSM transition that is not executed by an event: the FSM goes through such a transition on a timeout.
-
-
Field Summary
Fields Modifier and Type Field Description static StringTIMEOUT_THREAD_NAME_BASEThe base name (starts with) of the threads created for the timeout.-
Fields inherited from class io.github.interacto.fsm.Transition
src, tgt
-
-
Constructor Summary
Constructors Constructor Description TimeoutTransition(OutputState<E> srcState, InputState<E> tgtState, LongSupplier timeout)Creates the timeout transition.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanaccept(E event)Optional<InputState<E>>execute(E event)Executes the transition.Set<Object>getAcceptedEvents()protected booleanisGuardOK(E event)voidstartTimeout()Launches the timer.voidstopTimeout()Stops the timer.-
Methods inherited from class io.github.interacto.fsm.Transition
action, uninstall
-
-
-
-
Field Detail
-
TIMEOUT_THREAD_NAME_BASE
public static final String TIMEOUT_THREAD_NAME_BASE
The base name (starts with) of the threads created for the timeout.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TimeoutTransition
public TimeoutTransition(OutputState<E> srcState, InputState<E> tgtState, LongSupplier timeout)
Creates the timeout transition.- Parameters:
srcState- The source state of the transition.tgtState- The output state of the transition.timeout- The function that returns the timeout value in ms.- Throws:
IllegalArgumentException- If one of the states is null.
-
-
Method Detail
-
startTimeout
public void startTimeout()
Launches the timer.
-
stopTimeout
public void stopTimeout()
Stops the timer.
-
accept
protected boolean accept(E event)
- Specified by:
acceptin classTransition<E>
-
isGuardOK
protected boolean isGuardOK(E event)
- Specified by:
isGuardOKin classTransition<E>
-
execute
public Optional<InputState<E>> execute(E event) throws CancelFSMException
Description copied from class:TransitionExecutes the transition.- Overrides:
executein classTransition<E>- Parameters:
event- The event to process.- Returns:
- The potential output state.
- Throws:
CancelFSMException- If the execution cancels the FSM execution.
-
getAcceptedEvents
public Set<Object> getAcceptedEvents()
- Specified by:
getAcceptedEventsin classTransition<E>- Returns:
- The set of events accepted by the transition.
-
-