Class TransitionResolver

java.lang.Object
cloud.opencode.base.flow.internal.TransitionResolver

public final class TransitionResolver extends Object
Resolves "where to go next" given a FlowDefinition and the current step, plus locates a sensible "previous approve / vote" target for reject. 给定 FlowDefinition 与当前节点,解析下一步;为 reject 操作定位"上一个 approve / vote 节点"。
Since:
JDK 25, opencode-base-flow V1.0.5
Author:
Leon Soo
  • Constructor Details

    • TransitionResolver

      public TransitionResolver()
      Default constructor. 默认构造器。
      Since:
      JDK 25, opencode-base-flow V1.0.5
  • Method Details

    • nextStep

      public Optional<Step> nextStep(FlowDefinition def, String currentStepId)
      Returns the next Step for the given currentStepId based on the single outgoing Transition. Returns empty when no edge (i.e. current step is an END node or definition is malformed). 根据唯一出边返回下一步;无出边(如当前为 END 节点)时返回 empty。
      Parameters:
      def - flow definition — 流程定义
      currentStepId - current step id — 当前节点 id
      Returns:
      next step (Optional) — 下一步(Optional)
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • previousApproveOrVoteStep

      public Optional<Step> previousApproveOrVoteStep(List<HistoryRecord> history, FlowDefinition def)
      Returns the previous APPROVE / VOTE step recorded in the timeline of history. The lookup scans backwards starting one entry before the most recent one, skipping non-START/APPROVE/VOTE records and skipping the current step id (the one being rejected); the first hit's step_id is resolved against def. 反查 history 中"倒数第二条"APPROVE/VOTE/START 记录的 step_id,返回对应节点。
      Parameters:
      history - history records (any order; will be sorted by createdAt) — 历史记录
      def - flow definition — 流程定义
      Returns:
      previous approve/vote step — 上一审批/投票节点
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • previousApproveOrVoteStep

      public Optional<Step> previousApproveOrVoteStep(List<HistoryRecord> history, FlowDefinition def, String currentStepId)
      Variant that accepts an explicit current step id so callers (e.g. RejectOperation) can resolve the previous step BEFORE writing the REJECT history row. When currentStepId is null the method falls back to inferring it from the latest history record (the legacy behaviour). 显式传入当前节点 id 的重载;让调用方在写 REJECT 历史之前就能定位上一节点。
      Parameters:
      history - history records — 历史
      def - flow definition — 流程定义
      currentStepId - current step id (nullable) — 当前节点 id(可空)
      Returns:
      previous approve/vote step — 上一审批/投票节点
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • findStepById

      public Optional<Step> findStepById(FlowDefinition def, String stepId)
      Returns the Step with the given id from def.steps(). 在 def.steps() 中查找指定 id 节点。
      Parameters:
      def - flow definition — 流程定义
      stepId - step id — 节点 id
      Returns:
      matching step (Optional) — 匹配节点(Optional)
      Since:
      JDK 25, opencode-base-flow V1.0.5