Skip to content

Latest commit

 

History

History
44 lines (29 loc) · 2.04 KB

README.md

File metadata and controls

44 lines (29 loc) · 2.04 KB

A State Machine implementation in Java

Build Status Dependency Status Coverage Status

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();

State Machine used in the unit tests

Phone State Machine Diagram

Inspired by simplestatemachine

Phone State Machine (Generated from code by Graphviz)

Phone State Machine Diagram

ATM State Machine Diagram

Inspired by ATM Bank

ATM State Machine (Generated from code by Graphviz)

ATM State Machine

The composite state ServingCustomer

Serving Customer

A model containing the ATM state machine and the inner states of the composite state (not generated from code)

ATM State Machine Diagram