Skip to content

lind/machineprocess

Repository files navigation

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

About

Simple State Machine without sub-state machine, composite state, deferred signals, queues and no runtime engine environment.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages