public class CompletionStages extends Object
CompletionStage
instances.Modifier and Type | Field and Description |
---|---|
static Runnable |
NO_OP_RUNNABLE |
Modifier and Type | Method and Description |
---|---|
static AggregateCompletionStage<Void> |
aggregateCompletionStage()
Returns a CompletionStage that also can be composed of many other CompletionStages.
|
static <R> AggregateCompletionStage<R> |
aggregateCompletionStage(R valueToReturn)
Same as
aggregateCompletionStage() except that when this stage completes normally it will return
the value provided. |
static CompletionStage<Void> |
allOf(CompletionStage<?>... stages)
Returns a CompletionStage that completes when all of the provided stages complete, either normally or via
exception.
|
static CompletionStage<Void> |
allOf(CompletionStage<Void> first,
CompletionStage<Void> second)
Returns a CompletableStage that completes when both of the provides CompletionStages complete.
|
static <T,U> CompletionStage<U> |
handleAndCompose(CompletionStage<T> stage,
BiFunction<T,Throwable,CompletionStage<U>> handleFunction)
Extend
CompletionStage.thenCompose(Function) to also handle exceptions. |
static CompletionStage<Void> |
ignoreValue(CompletionStage<?> stage) |
static boolean |
isCompletedSuccessfully(CompletionStage<?> stage)
Returns if the provided
CompletionStage has already completed normally, that is not due to an exception. |
static <R> R |
join(CompletionStage<R> stage)
Returns the result value when complete, or throws an (unchecked) exception if completed exceptionally.
|
static <T> CompletionStage<T> |
schedule(Callable<T> command,
ScheduledExecutorService executor,
long delay,
TimeUnit timeUnit) |
static CompletionStage<Void> |
schedule(Runnable command,
ScheduledExecutorService executor,
long delay,
TimeUnit timeUnit) |
static <T> CompletionStage<T> |
scheduleNonBlocking(Callable<? extends CompletionStage<T>> command,
ScheduledExecutorService executor,
long delay,
TimeUnit timeUnit) |
public static final Runnable NO_OP_RUNNABLE
public static AggregateCompletionStage<Void> aggregateCompletionStage()
AggregateCompletionStage.dependsOn(CompletionStage)
method passing in the
CompletionStage. After all stages this composition stage depend upon have been added, the
AggregateCompletionStage.freeze()
should be invoked so that the AggregateCompletionStage can finally
complete when all of the stages it depends upon complete.
If any stage this depends upon fails the returned stage will contain the Throwable from one of the stages.
public static <R> AggregateCompletionStage<R> aggregateCompletionStage(R valueToReturn)
aggregateCompletionStage()
except that when this stage completes normally it will return
the value provided.R
- the type of the valuevalueToReturn
- value to return to future stage compositionspublic static boolean isCompletedSuccessfully(CompletionStage<?> stage)
CompletionStage
has already completed normally, that is not due to an exception.stage
- stage to checkpublic static <R> R join(CompletionStage<R> stage)
R
- the type in the stagestage
- stage to wait onCompletionException
- if this stage completed exceptionally or a completion computation threw an exceptionpublic static CompletionStage<Void> allOf(CompletionStage<Void> first, CompletionStage<Void> second)
first
- the first CompletionStagesecond
- the second CompletionStagepublic static CompletionStage<Void> allOf(CompletionStage<?>... stages)
stages
- the CompletionStagespublic static <T,U> CompletionStage<U> handleAndCompose(CompletionStage<T> stage, BiFunction<T,Throwable,CompletionStage<U>> handleFunction)
CompletionStage.thenCompose(Function)
to also handle exceptions.public static CompletionStage<Void> schedule(Runnable command, ScheduledExecutorService executor, long delay, TimeUnit timeUnit)
public static <T> CompletionStage<T> schedule(Callable<T> command, ScheduledExecutorService executor, long delay, TimeUnit timeUnit)
public static <T> CompletionStage<T> scheduleNonBlocking(Callable<? extends CompletionStage<T>> command, ScheduledExecutorService executor, long delay, TimeUnit timeUnit)
public static CompletionStage<Void> ignoreValue(CompletionStage<?> stage)
Copyright © 2021 JBoss by Red Hat. All rights reserved.