Kairos Automat
Kairos Automat is a finite-state machine (FSM) library
Kairos Automat aims to provide following features:
- Easy to use flat one level state machine for simple use cases
- Hierarchical state machine structure to ease complex state configuration
- Builder pattern for easy instantiation
- State entry/exit actions
- Extended state
- Transition actions
- State machine event listeners
Getting Started
enum class States {
S1, S2, S3
}
enum class Events {
E1, E2
}
val configurer = AutomatBuilder<States, Events>()
.withConfig()
.enableLogging()
configurer
.configureStates()
.initial(States.S1)
.states(States.values().toList())
.end(States.S3)
configurer
.configureTransitions()
.withExternal()
.event(Events.E1).source(States.S1).target(States.S2)
.and()
.withExternal()
.event(Events.E2).source(States.S2).target(States.S3)
val machine = configurer.build()
machine.start()
a.sendEvent(Events.E1)
a.sendEvent(Events.E2)
machine.stop()
Installing
Maven
<dependency>
<groupId>net.pechorina.kairos.automat</groupId>
<artifactId>kairos-automat</artifactId>
<version>0.2.0</version>
</dependency>
Gradle
compile 'net.pechorina.kairos.automat:kairos-automat:0.2.0'
Built With
- gradle - Dependency Management
- kotlin - Programming language for JVM
- kotlin-logging - A convenient and performant logging library wrapping slf4
Contributing
Pull requests are welcome!
Authors
- Victor Pechorin - Initial work - GitHub
License
This project is licensed under the Apache License Version 2.0 - see the LICENSE file for details
Acknowledgments
- Spring Statemachine for providing inspiration