!act,sam #3889 Adding Activator template FSM/become for Java with Lambda support

* Dining Hakkers Activator template for FSM and become
* Cleaup of FSM event matchers to be more usable and consistent
This commit is contained in:
Björn Antonsson 2014-02-24 12:11:02 +01:00
parent 6af33381b3
commit 07e361c684
30 changed files with 1026 additions and 103 deletions

View file

@ -47,7 +47,7 @@ public class Buncher extends AbstractFSM<State, Data> {
when(Active, Duration.create(1, "second"),
matchEvent(Arrays.asList(Flush.class, StateTimeout()), Todo.class,
todo -> goTo(Idle).using(todo.copy(new LinkedList<>()))));
(event, todo) -> goTo(Idle).using(todo.copy(new LinkedList<>()))));
//#unhandled-elided
whenUnhandled(

View file

@ -85,7 +85,7 @@ public class FSMDocTest {
//#alt-transition-syntax
//#stop-syntax
when(Error, matchEventEquals("stop", (data) -> {
when(Error, matchEventEquals("stop", (event, data) -> {
// do cleanup ...
return stop();
}));
@ -103,7 +103,7 @@ public class FSMDocTest {
//#unhandled-syntax
whenUnhandled(
matchEvent(X.class, null, (x, data) -> {
matchEvent(X.class, (x, data) -> {
log().info("Received unhandled event: " + x);
return stay();
}).
@ -146,7 +146,7 @@ public class FSMDocTest {
target.tell("going active", self());
return goTo(Active);
}));
when(Active, matchEventEquals("stop", (data) -> {
when(Active, matchEventEquals("stop", (event, data) -> {
target.tell("stopping", self());
return stop(new Failure("This is not the error you're looking for"));
}));