【问题标题】:How to check if the event triggers the state machine in Spring Statemachine?Spring Statemachine中如何检查事件是否触发了状态机?
【发布时间】:2021-09-15 16:46:47
【问题描述】:

让我将我的问题总结如下,

我知道stateMachine.sendEvent(Event e) 返回一个布尔值表示事件是否触发转换,但如果true 也会触发转换。

但是,我只想检查状态机是否可以被该事件触发,而不是在之后触发转换。有什么办法吗?

【问题讨论】:

    标签: spring spring-boot spring-statemachine


    【解决方案1】:

    没有内置方法可以做到这一点,但是一旦您检索到 StateMachine 的实例,您就可以实现一个方法来遍历转换以查找当前状态并检查该状态的可用转换。每个 AbstractTransition 包含一个源和目标状态

    machine.getTransitions()
    

    【讨论】:

      猜你喜欢
      • 2013-07-31
      • 2014-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多