From 9db96a2b37c4b44df43fd5141604d292fac6c71b Mon Sep 17 00:00:00 2001 From: Vyacheslav Boyko Date: Thu, 14 Jul 2022 15:36:25 +0300 Subject: [PATCH] before handler must be called right before switching to the next state --- src/main/java/me/bvn13/fsm/Fsm.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/bvn13/fsm/Fsm.java b/src/main/java/me/bvn13/fsm/Fsm.java index 39b1a81..f724986 100644 --- a/src/main/java/me/bvn13/fsm/Fsm.java +++ b/src/main/java/me/bvn13/fsm/Fsm.java @@ -149,9 +149,9 @@ public class Fsm { return; } currentState.process(event); - currentState.afterEvent(); if (currentState.isFinish()) { done = true; + currentState.afterEvent(); return; } switchToNextState(event); @@ -278,6 +278,7 @@ public class Fsm { } private void nextState(State state, E event) { + currentState.afterEvent(); previousState = currentState; currentState = state; currentState.beforeEvent();