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