Skip to content

Commit

Permalink
fix:condition被执行了两次
Browse files Browse the repository at this point in the history
  • Loading branch information
shenjianeng committed Apr 9, 2022
1 parent 1c35fd6 commit 0d69547
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public interface Transition<S, E, C>{
* @return the target state
*/

State<S,E,C> transit(C ctx);
State<S, E, C> transit(C ctx, boolean checkCondition);
/**
* Verify transition correctness
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public S fireEvent(S sourceStateId, E event, C ctx) {
return sourceStateId;
}

return transition.transit(ctx).getId();
return transition.transit(ctx, false).getId();
}

private Transition<S, E, C> routeTransition(S sourceStateId, E event, C ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public void setAction(Action<S, E, C> action) {
}

@Override
public State<S, E, C> transit(C ctx) {
public State<S, E, C> transit(C ctx, boolean checkCondition) {
Debugger.debug("Do transition: "+this);
this.verify();
if(condition == null || condition.isSatisfied(ctx)){
if (!checkCondition || condition == null || condition.isSatisfied(ctx)) {
if(action != null){
action.execute(source.getId(), target.getId(), event, ctx);
}
Expand Down

0 comments on commit 0d69547

Please sign in to comment.