public final class CompletionStages
extends java.lang.Object
Utility class for creating different kinds of CompletionStage
.
Modifier and Type | Method and Description |
---|---|
static <T> java.util.concurrent.CompletionStage<java.util.List<T>> |
allOf(java.util.Collection<? extends java.util.concurrent.CompletionStage<java.util.List<T>>> stages)
Returns a completion stage, which is complete when all the completion stages are complete.
|
static <T> java.util.concurrent.CompletionStage<T> |
timeoutAfter(long delay,
java.util.concurrent.TimeUnit unit)
Creates a completion stage, which times out after the specified time, i.e. it completes exceptionally with a
TimeoutException . |
static <T> java.util.concurrent.CompletionStage<T> |
timeoutAfter(long delay,
java.util.concurrent.TimeUnit unit,
java.util.function.Supplier<java.lang.Throwable> throwableSupplier)
Creates a completion stage, which times out after the specified time, i.e. it completes exceptionally with the supplied exception.
|
static <T> java.util.concurrent.CompletionStage<T> |
withFallback(java.util.concurrent.CompletionStage<T> stage,
java.util.function.BiFunction<java.util.concurrent.CompletionStage<T>,java.lang.Throwable,? extends java.util.concurrent.CompletionStage<T>> fallback)
Creates a new completion stage which uses a fallback stage in case the primary stage completes exceptionally.
|
public static <T> java.util.concurrent.CompletionStage<T> withFallback(java.util.concurrent.CompletionStage<T> stage, java.util.function.BiFunction<java.util.concurrent.CompletionStage<T>,java.lang.Throwable,? extends java.util.concurrent.CompletionStage<T>> fallback)
Creates a new completion stage which uses a fallback stage in case the primary stage completes exceptionally.
T
- The type.stage
- The primary stage.fallback
- A function, which returns a fallback stage, in case the primary one fails exceptionally.public static <T> java.util.concurrent.CompletionStage<java.util.List<T>> allOf(java.util.Collection<? extends java.util.concurrent.CompletionStage<java.util.List<T>>> stages)
Returns a completion stage, which is complete when all the completion stages are complete. The lists of each stage are flat mapped into one list, so that the returned stage has one accumulated list.
T
- The type.stages
- The stages.public static <T> java.util.concurrent.CompletionStage<T> timeoutAfter(long delay, java.util.concurrent.TimeUnit unit)
Creates a completion stage, which times out after the specified time, i.e. it completes exceptionally with a TimeoutException
.
T
- The type.delay
- The delay.unit
- The time unit.public static <T> java.util.concurrent.CompletionStage<T> timeoutAfter(long delay, java.util.concurrent.TimeUnit unit, java.util.function.Supplier<java.lang.Throwable> throwableSupplier)
Creates a completion stage, which times out after the specified time, i.e. it completes exceptionally with the supplied exception.
T
- The type.delay
- The delay.unit
- The time unit.throwableSupplier
- The supplier for an exception which occurs on timeout.Copyright © 2014–2019 XMPP.rocks. All rights reserved.