net.digger:state-machine

A state machine implementation.

License

License

Categories

Categories

Net
GroupId

GroupId

net.digger
ArtifactId

ArtifactId

state-machine
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

net.digger:state-machine
A state machine implementation.
Project URL

Project URL

https://github.com/diggernet/StateMachine
Source Code Management

Source Code Management

https://github.com/diggernet/StateMachine/tree/develop

Download state-machine

How to add to project

<!-- https://jarcasting.com/artifacts/net.digger/state-machine/ -->
<dependency>
    <groupId>net.digger</groupId>
    <artifactId>state-machine</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/net.digger/state-machine/
implementation 'net.digger:state-machine:1.0.0'
// https://jarcasting.com/artifacts/net.digger/state-machine/
implementation ("net.digger:state-machine:1.0.0")
'net.digger:state-machine:jar:1.0.0'
<dependency org="net.digger" name="state-machine" rev="1.0.0">
  <artifact name="state-machine" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.digger', module='state-machine', version='1.0.0')
)
libraryDependencies += "net.digger" % "state-machine" % "1.0.0"
[net.digger/state-machine "1.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

StateMachine

StateMachine is a Java implementation of a state machine. It was inspired by the state machine in Joshua Haberman's vtparse.

Maven configuration

	<dependency>
		<groupId>net.digger</groupId>
		<artifactId>state-machine</artifactId>
		<version>1.0.0</version>
	</dependency>

Usage

  • Extend the StateMachine class, providing enums for Action and State, and your Event type.
  • Instantiate your class, providing and initial State and an Action handler.
  • Call addState() to create states, providing a State, optional entry and exit Actions, and an initialization callback. The callback will receive an instance of StateData, which is can use to add events to the state using addEvent(), providing an Event, an optional Action to take, and an optional State to transition to.
  • When initialization is complete, you can use handleEvent() to process each Event, which will call your Action handler as appropriate.
  • You can also call reset() to reset the state machine to its initial condition, or getDOT() to retrieve the current state machine as a DOT string, suitable for rendering with Graphviz.

VTParser is implemented using StateMachine.

License

StateMachine is provided under the terms of the GNU LGPLv3.

Versions

Version
1.0.0