Class CompletableFutures
java.lang.Object
org.infinispan.commons.util.concurrent.CompletableFutures
Utility methods connecting
CompletableFuture
futures.- Since:
- 8.0
- Author:
- Dan Berindei
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CompletionException
static boolean
await
(CompletableFuture<?> future, long time, TimeUnit unit) It waits until theCompletableFuture
is completed.static <T> T
await
(CompletableFuture<T> future) Wait for a long time until theCompletableFuture
is 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 Throwable
static <T> Function
<T, T> identity()
static void
static <T> CompletableFuture
<List<T>> sequence
(List<CompletableFuture<T>> futures) static <T,
R> Function <T, R> static boolean
uncheckedAwait
(CompletableFuture<?> future, long time, TimeUnit unit) Same asawait(CompletableFuture, long, TimeUnit)
but wraps checked exceptions inCacheException
static <T> T
uncheckedAwait
(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 theCompletableFuture
is completed.It ignore if the
CompletableFuture
is completed normally or exceptionally.- Parameters:
future
- theCompletableFuture
to test.time
- the timeout.unit
- the timeout unit.- Returns:
true
if completed,false
if timed out.- Throws:
InterruptedException
- if interrupted while waiting.NullPointerException
- iffuture
orunit
isnull
.
-
uncheckedAwait
Same asawait(CompletableFuture, long, TimeUnit)
but wraps checked exceptions inCacheException
- Parameters:
future
- theCompletableFuture
to test.time
- the timeout.unit
- the timeout unit.- Returns:
true
if completed,false
if timed out.- Throws:
NullPointerException
- iffuture
orunit
isnull
.
-
await
public static <T> T await(CompletableFuture<T> future) throws ExecutionException, InterruptedException Wait for a long time until theCompletableFuture
is completed.- Type Parameters:
T
- the return type.- Parameters:
future
- theCompletableFuture
.- Returns:
- the result value.
- Throws:
ExecutionException
- if theCompletableFuture
completed 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
-