Simple State Machine with transitions, guards, composite state.
...but without sub-state machine, deferred signals, event queues...
Define the State Machine by subclassing State Machine and using the builders in the constructor. Se tests for usage.
State onHold = state(ON_HOLD)
.transition(HURL_PHONE).guardedBy(event -> PHONE_HURLED_AGAINST_WALL.equals(event.getName()))
.to(phoneDestroyed)
.transition(HANG_UP).guardedBy(event -> HUNG_UP.equals(event.getName()))
.to(offHook)
.transition(TAKE_OFF_HOLD).onTransition(stopMuzak).guardedBy(event -> TOOK_OFF_HOLD.equals(event.getName()))
.to(connected)
.build();
Inspired by simplestatemachine
Phone State Machine (Generated from code by Graphviz)
Inspired by ATM Bank
ATM State Machine (Generated from code by Graphviz)
The composite state ServingCustomer
A model containing the ATM state machine and the inner states of the composite state (not generated from code)