Class TransitionResolver
java.lang.Object
cloud.opencode.base.flow.internal.TransitionResolver
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindStepById(FlowDefinition def, String stepId) Returns theStepwith the given id fromdef.steps().nextStep(FlowDefinition def, String currentStepId) previousApproveOrVoteStep(List<HistoryRecord> history, FlowDefinition def) Returns the previous APPROVE / VOTE step recorded in the timeline ofhistory.previousApproveOrVoteStep(List<HistoryRecord> history, FlowDefinition def, String currentStepId) Variant that accepts an explicit current step id so callers (e.g.
-
Constructor Details
-
TransitionResolver
public TransitionResolver()Default constructor. 默认构造器。- Since:
- JDK 25, opencode-base-flow V1.0.5
-
-
Method Details
-
nextStep
Returns the nextStepfor the givencurrentStepIdbased on the single outgoingTransition. 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
Returns the previous APPROVE / VOTE step recorded in the timeline ofhistory. 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'sstep_idis resolved againstdef. 反查 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. WhencurrentStepIdisnullthe 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
- Parameters:
def- flow definition — 流程定义stepId- step id — 节点 id- Returns:
- matching step (Optional) — 匹配节点(Optional)
- Since:
- JDK 25, opencode-base-flow V1.0.5
-