before handler must be called right before switching to the next state

This commit is contained in:
Vyacheslav Boyko 2022-07-14 15:36:25 +03:00
parent 4712c1b423
commit 9db96a2b37

View File

@ -149,9 +149,9 @@ public class Fsm<T extends Fsm, E> {
return;
}
currentState.process(event);
currentState.afterEvent();
if (currentState.isFinish()) {
done = true;
currentState.afterEvent();
return;
}
switchToNextState(event);
@ -278,6 +278,7 @@ public class Fsm<T extends Fsm, E> {
}
private void nextState(State<E> state, E event) {
currentState.afterEvent();
previousState = currentState;
currentState = state;
currentState.beforeEvent();