public class Collect<I,O> extends CoroutineStep<I,java.util.Collection<O>>
when(Predicate). Also by default all coroutines will be awaited before resuming but that can be controlled with
until(Predicate). If the collecting is finished all coroutines that are still running will be cancelled.
To select exactly only one result from multiple coroutines the related
Select can be used.
|Constructor and Description|
Creates a new instance.
|Modifier and Type||Method and Description|
Creates a new instance that collects the result of an additional coroutine.
Creates a new instance that collects the result of an additional step.
Suspends the coroutine execution until all coroutines finish and then resumes the execution with a collection of the results.
Suspends the coroutine execution until one coroutine step finishes.
This method must be implemented by subclasses to provide the actual functionality of this step.
Runs this execution step asynchronously as a continuation of a previous code execution in a
Adds a condition for the termination of the result collection.
Adds a condition for the result collection.
fail, runBlocking, terminateCoroutine, toString
deleteRelation, get, getRelation, getRelations, notifyRelationListeners, readRelations, relationsEqual, relationsHashCode, relationsString, set, set, transform, writeRelations
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
deleteRelation, deleteRelation, deleteRelations, get, get, get, getAll, getRelation, getRelationCount, getRelations, getRelations, hasFlag, hasRelation, hasRelations, init, set, set, set, set, set, streamRelations, transform
@SafeVarargs public static <I,O> Collect<I,O> collect(Coroutine<? super I,? extends O>... rFromCoroutines)
until(Predicate)which will return a new
Collectinstance. Modified instances that select from additional coroutines or steps can be created with
rFromCoroutines- The coroutines to select from
@SafeVarargs public static <I,O> Collect<I,O> collect(CoroutineStep<? super I,? extends O>... rFromSteps)
rFromSteps- The coroutine steps to select from
rCoroutine- The additional coroutine to select from
rStep- The additional step to select from
public void runAsync(java.util.concurrent.CompletableFuture<I> fPreviousExecution, CoroutineStep<java.util.Collection<O>,?> rNextStep, Continuation<?> rContinuation)
CompletableFutureand proceeds to the next step afterwards.
Subclasses that need to suspend the invocation of the next step until
some condition is met (e.g. sending or receiving data has finished) need
to override this method and create a
Suspension by invoking
Continuation.suspend(CoroutineStep, CoroutineStep) on the next
step. If the condition that caused the suspension resolves the coroutine
execution can be resumed by calling
Subclasses that override this method also need to handle errors by
terminating any further execution (i.e. not resuming a suspension if such
exists) and forwarding the causing exception to
public Collect<I,O> until(java.util.function.Predicate<Continuation<?>> pCompletionCriteria)
Any collection criteria provided through
not automatically applied to the completion criteria and must therefore
be handled explicitly in the completion test if necessary.
pCompletionCriteria- A condition that checks if a result should be selected
public Collect<I,O> when(java.util.function.Predicate<Continuation<?>> pCollectCriteria)
pCollectCriteria- A condition that checks if a result should be collected
protected java.util.Collection<O> execute(I rInput, Continuation<?> rContinuation)