batuhancan
batuhancan

Reputation: 37

How to check if the event triggers the state machine in Spring Statemachine?

Let me summarize my question as follows,

I know that the stateMachine.sendEvent(Event e) returns a boolean value representing if the event triggers a transition or not, but it also triggers the transition if true.

However, I want only to check if the state machine is triggerable by that event or not, and not to trigger the transition afterwards. Is there any way to do that?

Upvotes: 2

Views: 1123

Answers (1)

Daniel Vilas-Boas
Daniel Vilas-Boas

Reputation: 896

There is no built-in method to do that, but once you retrieve an instance of a StateMachine, you can implement a method to iterate over the transitions looking for the current state and check what are the available transitions for that state. Each AbstractTransition contains a source and target state

machine.getTransitions()

Debugging example

Upvotes: 1

Related Questions