Class AnyMatchCombinatorDelegate
- All Implemented Interfaces:
AnyMatchCombinator
AnyMatchCombinator.- Since:
- 5.4.0
- Author:
- Stefan Dragisic
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAnyMatchCombinatorDelegate(WorkflowExecution workflowExecution) Creates a new delegate backed by the given workflow state. -
Method Summary
Modifier and TypeMethodDescriptionanyMatch(Predicate<WorkflowStepResult> predicate, WorkflowStepResult... results) Predicate-based combinator — resolves when the first completed result matches the given predicate.
-
Constructor Details
-
AnyMatchCombinatorDelegate
Creates a new delegate backed by the given workflow state.- Parameters:
workflowExecution- the workflow execution.
-
-
Method Details
-
anyMatch
public CombinatorWorkflowStepResult anyMatch(Predicate<WorkflowStepResult> predicate, WorkflowStepResult... results) Description copied from interface:AnyMatchCombinatorPredicate-based combinator — resolves when the first completed result matches the given predicate. Replaces both the formerrace()andanySuccessful()methods:anyMatch(state, WorkflowStepResult::isCompleted, ...)— any terminal wins (oldrace)anyMatch(state, WorkflowStepResult::isSuccess, ...)— first success wins (oldanySuccessful)- Also works with
::isFailure,::isTimeout,::isCanceled
Winner selection
The composite blocks until at least one completed result matches the predicate. That result becomes the winner and the composite delegates every state query (
isSuccess(),isFailure(),result(),error(), etc.) to it.Fallback
When all results complete but none matched the predicate, the first completed result (by event-sourced timestamp) becomes the consolation winner.
Loser handling
Losers are not automatically cancelled. The caller is responsible for cancelling remaining results if desired.
Event-sourcing replay safety
When multiple steps match the predicate before cancellation takes effect (e.g. during event replay), the winner is determined by event-sourced timestamps, not by array order.
Completion
isCompleted()is non-blocking and returnstruewhen any completed result matches the predicate or when all results have reached a terminal state.Cancellation
cancel()andcancel(reason)propagate to all results.Result categorization
The returned
CombinatorWorkflowStepResultprovidesmatched()andunmatched()to access categorized sub-results.matched()returns all completed results that satisfy the predicate at the time of the call — not just the winner. Because other steps may complete between resolution and callingmatched(), the list can contain more than one result. The winner (used forsuccess()/failure()/result()delegation) is always the first element.For
anyMatch(WorkflowStepResult::success, fastStep, slowStep)where fastStep succeeds and slowStep is still running:matched()→ [fastStep] — completed results that satisfiedsuccess()unmatched()→ [slowStep] — all other results, including those not yet completed
- Specified by:
anyMatchin interfaceAnyMatchCombinator- Parameters:
predicate- the predicate to match against completed results.results- the competing step results.- Returns:
- a composite result that resolves to the first matching result, or fallback to first completed.
-