Compare commits
10 Commits
81c5deb923
...
a96d0060ed
Author | SHA1 | Date |
---|---|---|
Vyacheslav Boyko | a96d0060ed | |
Vyacheslav Boyko | af3a663c79 | |
Vyacheslav Boyko | a32dabbb39 | |
Vyacheslav Boyko | 6fb337ce01 | |
Vyacheslav Boyko | 4ba45f2c27 | |
Vyacheslav Boyko | a07e78d1fe | |
Vyacheslav Boyko | 5ea8db0c8a | |
Vyacheslav Boyko | aa6b589591 | |
Vyacheslav Boyko | f7852f1158 | |
Vyacheslav Boyko | 5f64ba7f5c |
2
pom.xml
2
pom.xml
|
@ -7,7 +7,7 @@
|
|||
|
||||
<groupId>me.bvn13</groupId>
|
||||
<artifactId>fsm</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<version>2.1.3</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.function.Supplier;
|
|||
* <p>
|
||||
* <b>Final State Machine</b>
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Each state machine must be prepared with:
|
||||
* <ol>
|
||||
|
@ -25,7 +26,6 @@ import java.util.function.Supplier;
|
|||
* <li>Intermediate states - optionally</li>
|
||||
* <li>All transitions needed</li>
|
||||
* </ol>
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Each {@link State} may be specified with handlers:
|
||||
|
@ -34,7 +34,6 @@ import java.util.function.Supplier;
|
|||
* <li>After handler - is called right before FSM changes FROM this state to another</li>
|
||||
* <li>Processor - the method to process events</li>
|
||||
* </ol>
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Transition is the Rule providing FSM the possibility to change between states.
|
||||
|
@ -46,12 +45,10 @@ import java.util.function.Supplier;
|
|||
* <li>Condition - optionally. If specified, the FSM will check the condition in order to check the possibility
|
||||
* to change from FROM State into TO State</li>
|
||||
* </ol>
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Simple way to use it - to construct an inherited class specified with the type of events to be processed
|
||||
* during transitions.
|
||||
* </p>
|
||||
*
|
||||
* <pre>
|
||||
* {@code
|
||||
|
@ -79,35 +76,29 @@ import java.util.function.Supplier;
|
|||
*
|
||||
* <p>
|
||||
* Otherwise you are able to use Old syntax:
|
||||
* </p>
|
||||
*
|
||||
* <pre>
|
||||
* {@code
|
||||
* NamedFsm namedFsm = new NamedFsm().setName("TEST FSM");
|
||||
* namedFsm.initState(new State<String>("init") {
|
||||
* @Override
|
||||
* namedFsm.initState(new State<String>("init") {
|
||||
* public void process(String event) {
|
||||
* initStatedProcessed.set(true);
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* namedFsm.addTransition("init", new State<String>("first", true) {
|
||||
* @Override
|
||||
* namedFsm.addTransition("init", new State<String>("first", true) {
|
||||
* public void process(String event) {
|
||||
* firstStatedProcessed.set(true);
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* namedFsm.addTransition("init", new State<String>("another", true) {
|
||||
* @Override
|
||||
* namedFsm.addTransition("init", new State<String>("another", true) {
|
||||
* public void process(String event) {
|
||||
* anotherStatedProcessed.set(true);
|
||||
* }
|
||||
* }, (fsm, event) -> false);
|
||||
* }, (fsm, event) -> false);
|
||||
*
|
||||
* namedFsm.init();
|
||||
* }
|
||||
* </pre> *
|
||||
* </pre>
|
||||
* {@link SimpleFsm}
|
||||
*/
|
||||
public class Fsm<T extends Fsm, E> {
|
||||
|
|
|
@ -2,7 +2,7 @@ package me.bvn13.fsm;
|
|||
|
||||
/**
|
||||
* State handler
|
||||
* @param <T>
|
||||
* @param <T> class inherited from {@link Fsm}
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface StateHandler<T extends Fsm> {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package me.bvn13.fsm.exceptions;
|
||||
|
||||
/**
|
||||
* is thrown in case of adding a transition <code>FROM->TO</code>, but it is already defined
|
||||
* is thrown in case of adding a transition <code>FROM - TO</code>, but it is already defined
|
||||
*/
|
||||
public class ConditionAlreadyExistsException extends FsmException {
|
||||
public ConditionAlreadyExistsException(String from, String to) {
|
||||
|
|
Loading…
Reference in New Issue