public class CompletableFutures extends Object
CompletableFuture
futures.Modifier and Type | Field and Description |
---|---|
static CompletableFuture[] |
EMPTY_ARRAY |
Constructor and Description |
---|
CompletableFutures() |
public static final CompletableFuture[] EMPTY_ARRAY
public static <K,V> CompletableFuture<Map<K,V>> completedEmptyMap()
public static <T> CompletableFuture<T> completedNull()
public static CompletableFuture<Boolean> completedTrue()
public static CompletableFuture<Boolean> completedFalse()
public static CompletionStage<Boolean> booleanStage(boolean trueOrFalse)
public static <T> CompletableFuture<List<T>> sequence(List<CompletableFuture<T>> futures)
public static <T> CompletableFuture<T> completedExceptionFuture(Throwable ex)
public static boolean await(CompletableFuture<?> future, long time, TimeUnit unit) throws InterruptedException
CompletableFuture
is completed.
It ignore if the CompletableFuture
is completed normally or exceptionally.
future
- the CompletableFuture
to test.time
- the timeout.unit
- the timeout unit.true
if completed, false
if timed out.InterruptedException
- if interrupted while waiting.NullPointerException
- if future
or unit
is null
.public static boolean uncheckedAwait(CompletableFuture<?> future, long time, TimeUnit unit)
await(CompletableFuture, long, TimeUnit)
but wraps checked exceptions in CacheException
future
- the CompletableFuture
to test.time
- the timeout.unit
- the timeout unit.true
if completed, false
if timed out.NullPointerException
- if future
or unit
is null
.public static <T> T await(CompletableFuture<T> future) throws ExecutionException, InterruptedException
CompletableFuture
is completed.T
- the return type.future
- the CompletableFuture
.ExecutionException
- if the CompletableFuture
completed exceptionally.InterruptedException
- if the current thread was interrupted while waiting.public static <T> T uncheckedAwait(CompletableFuture<T> future)
await(CompletableFuture)
but wraps checked exceptions in CacheException
T
- the return type.future
- the CompletableFuture
.public static CompletionException asCompletionException(Throwable t)
public static void rethrowExceptionIfPresent(Throwable t)
public static <T,R> Function<T,R> toNullFunction()
Copyright © 2021 JBoss by Red Hat. All rights reserved.