Interface CombinatorWorkflowStepResult
- All Superinterfaces:
WorkflowStepResult
AnyMatchCombinator.anyMatch(java.util.function.Predicate<io.axoniq.framework.workflow.dsl.api.WorkflowStepResult>, io.axoniq.framework.workflow.dsl.api.WorkflowStepResult...), NoneMatchCombinator.noneMatch(java.util.function.Predicate<io.axoniq.framework.workflow.dsl.api.WorkflowStepResult>, io.axoniq.framework.workflow.dsl.api.WorkflowStepResult...),
AllMatchCombinator.allMatch(java.util.function.Predicate<io.axoniq.framework.workflow.dsl.api.WorkflowStepResult>, io.axoniq.framework.workflow.dsl.api.WorkflowStepResult...)) are required to return.
In addition to the standard WorkflowStepResult queries (success(),
failure(), result(), etc.), this interface exposes the categorized sub-results split by the
combinator's predicate.
Both matched() and unmatched() block until the combinator has resolved
(consistent with success()/failure()). The returned lists are unmodifiable. Together they always
cover all input results: matched().size() + unmatched().size() == all input results.
matched() is sorted by event-sourced timestamps (earliest first) and contains only
completed sub-results. unmatched() lists completed results (sorted by timestamp) first, followed by
not-yet-completed results in their original array order.
How matched() and unmatched() apply to each combinator
anyMatch(WorkflowStepResult::success, stepA, stepB, stepC)
Predicate: success(). Suppose stepA succeeded, stepB failed, stepC succeeded.
The combinator resolves on the first success (the winner), but matched() returns
all completed results that satisfy the predicate at the time of the call.
The winner is always the first element.
matched()→ [stepA, stepC] — all completed successes (winner first)unmatched()→ [stepB] — the unsuccessful steps
noneMatch(WorkflowStepResult::failure, failingStep, slowStep)
Predicate: failure(). failingStep fails in 500ms, slowStep is still running.
matched()→ [failingStep] — triggered the failure predicate (violator!)unmatched()→ [slowStep] — not yet completed, still in the list
allMatch(WorkflowStepResult::success, stepA, stepB, stepC)
Predicate: success(). Suppose stepA succeeded, stepB failed (short-circuits), stepC still running.
matched()→ [stepA] — the successful stepsunmatched()→ [stepB, stepC] — the failed step (violator!) and the still-running step
Short-circuit and non-completed results
matched() and unmatched() reflect a snapshot of each result's state
at the time they are called — not the final outcome. Categorization is purely based on
isCompleted() && predicate.test() at that moment.
Because combinators short-circuit, some results may not have completed yet when
matched()/unmatched() is called. Those not-yet-completed results always
appear in unmatched(), even if they would satisfy the predicate once they complete.
Conversely, for anyMatch, the combinator resolves on the first match,
but other results may complete and satisfy the predicate before matched() is called.
In that case, matched() will contain multiple results — not just the winner.
The winner (used for success()/failure()/result() delegation) is
always the first element of matched().
Callers can always query individual results directly
(e.g. r.failure(), r.isCompleted()) regardless of which list they are in.
- Since:
- 5.4.0
- Author:
- Stefan Dragisic
-
Method Details
-
matched
List<WorkflowStepResult> matched()Returns all completed sub-results that satisfy the combinator's predicate at the time of this call. ForanyMatch, this may include more than just the winner if other results completed and matched between resolution and this call — the winner is always the first element.Blocks until the combinator has resolved. The returned list is unmodifiable and sorted by event-sourced timestamps (earliest first).
- Returns:
- an unmodifiable list of matching sub-results, sorted by event-sourced timestamp.
-
unmatched
List<WorkflowStepResult> unmatched()Returns all other sub-results that are not inmatched(). This may include results that have not yet completed, as well as completed results that did not satisfy the predicate. In short-circuit scenarios, a result may appear here even if its status would technically satisfy the predicate — it simply was not the one that triggered the combinator's resolution.Blocks until the combinator has resolved. The returned list is unmodifiable. Completed results appear first (sorted by event-sourced timestamps), followed by not-yet-completed results in their original array order.
- Returns:
- an unmodifiable list of non-matching sub-results.
-