Class CompletableFutures
java.lang.Object
org.infinispan.commons.util.concurrent.CompletableFutures
Utility methods connecting
CompletableFuture futures.- Since:
- 8.0
- Author:
- Dan Berindei
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic CompletionExceptionstatic booleanawait(CompletableFuture<?> future, long time, TimeUnit unit) It waits until theCompletableFutureis completed.static <T> Tawait(CompletableFuture<T> future) Wait for a long time until theCompletableFutureis completed.static CompletionStage<Boolean> booleanStage(boolean trueOrFalse) static <K,V> CompletableFuture <Map<K, V>> static CompletableFuture<Boolean> static <T> CompletableFuture<T> static CompletableFuture<Boolean> static Throwablestatic <T> Function<T, T> identity()static voidstatic <T> CompletableFuture<List<T>> sequence(List<CompletableFuture<T>> futures) static <T,R> Function <T, R> static booleanuncheckedAwait(CompletableFuture<?> future, long time, TimeUnit unit) Same asawait(CompletableFuture, long, TimeUnit)but wraps checked exceptions inCacheExceptionstatic <T> TuncheckedAwait(CompletableFuture<T> future) Same asawait(CompletableFuture)but wraps checked exceptions inCacheException
-
Field Details
-
EMPTY_ARRAY
-
-
Method Details
-
completedEmptyMap
-
completedNull
-
completedTrue
-
completedFalse
-
booleanStage
-
sequence
-
await
public static boolean await(CompletableFuture<?> future, long time, TimeUnit unit) throws InterruptedException It waits until theCompletableFutureis completed.It ignore if the
CompletableFutureis completed normally or exceptionally.- Parameters:
future- theCompletableFutureto test.time- the timeout.unit- the timeout unit.- Returns:
trueif completed,falseif timed out.- Throws:
InterruptedException- if interrupted while waiting.NullPointerException- iffutureorunitisnull.
-
uncheckedAwait
Same asawait(CompletableFuture, long, TimeUnit)but wraps checked exceptions inCacheException- Parameters:
future- theCompletableFutureto test.time- the timeout.unit- the timeout unit.- Returns:
trueif completed,falseif timed out.- Throws:
NullPointerException- iffutureorunitisnull.
-
await
public static <T> T await(CompletableFuture<T> future) throws ExecutionException, InterruptedException Wait for a long time until theCompletableFutureis completed.- Type Parameters:
T- the return type.- Parameters:
future- theCompletableFuture.- Returns:
- the result value.
- Throws:
ExecutionException- if theCompletableFuturecompleted exceptionally.InterruptedException- if the current thread was interrupted while waiting.
-
uncheckedAwait
Same asawait(CompletableFuture)but wraps checked exceptions inCacheException- Type Parameters:
T- the return type.- Parameters:
future- theCompletableFuture.- Returns:
- the result value.
-
asCompletionException
-
rethrowExceptionIfPresent
-
extractException
-
toNullFunction
-
toTrueFunction
-
identity
-