public final class MoreFutures extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
MoreFutures.ValueSupplier<T> |
| Modifier and Type | Method and Description |
|---|---|
static <T> CompletableFuture<T> |
addTimeout(CompletableFuture<T> future,
MoreFutures.ValueSupplier<T> onTimeout,
Duration timeout,
ScheduledExecutorService executorService)
Returns a new future that is completed when the supplied future completes or
when the timeout expires.
|
static <V> CompletableFuture<List<V>> |
allAsList(List<CompletableFuture<? extends V>> futures)
Returns an unmodifiable future that is completed when all of the given
futures complete.
|
static <V> CompletableFuture<V> |
failedFuture(Throwable throwable)
Returns a failed future containing the specified throwable.
|
static <V> CompletableFuture<V> |
firstCompletedFuture(Iterable<? extends CompletionStage<? extends V>> futures)
Creates a future that completes when the first future completes either normally
or exceptionally.
|
static <V> CompletableFuture<V> |
firstCompletedFuture(Iterable<? extends CompletionStage<? extends V>> futures,
boolean propagateCancel)
Creates a future that completes when the first future completes either normally
or exceptionally.
|
static <V> V |
getFutureValue(Future<V> future)
Waits for the value from the future.
|
static <V,E extends Exception> |
getFutureValue(Future<V> future,
Class<E> exceptionType)
Waits for the value from the future.
|
static <V> CompletableFuture<V> |
toCompletableFuture(com.google.common.util.concurrent.ListenableFuture<V> listenableFuture)
Converts a ListenableFuture to a CompletableFuture.
|
static <V> com.google.common.util.concurrent.ListenableFuture<V> |
toListenableFuture(CompletableFuture<V> completableFuture)
Converts a CompletableFuture to a ListenableFuture.
|
static <T> Optional<T> |
tryGetFutureValue(Future<T> future)
Gets the current value of the future without waiting.
|
static <V> Optional<V> |
tryGetFutureValue(Future<V> future,
int timeout,
TimeUnit timeUnit)
Waits for the the value from the future for the specified time.
|
static <V,E extends Exception> |
tryGetFutureValue(Future<V> future,
int timeout,
TimeUnit timeUnit,
Class<E> exceptionType)
Waits for the the value from the future for the specified time.
|
static <V> CompletableFuture<V> |
unmodifiableFuture(CompletableFuture<V> future)
Returns a future that can not be completed or canceled.
|
static <V> CompletableFuture<V> |
unmodifiableFuture(CompletableFuture<V> future,
boolean propagateCancel)
Returns a future that can not be completed or optionally canceled.
|
public static <V> CompletableFuture<V> unmodifiableFuture(CompletableFuture<V> future)
public static <V> CompletableFuture<V> unmodifiableFuture(CompletableFuture<V> future, boolean propagateCancel)
public static <V> CompletableFuture<V> failedFuture(Throwable throwable)
public static <V> V getFutureValue(Future<V> future)
public static <V,E extends Exception> V getFutureValue(Future<V> future, Class<E> exceptionType) throws E extends Exception
E extends Exceptionpublic static <T> Optional<T> tryGetFutureValue(Future<T> future)
public static <V> Optional<V> tryGetFutureValue(Future<V> future, int timeout, TimeUnit timeUnit)
public static <V,E extends Exception> Optional<V> tryGetFutureValue(Future<V> future, int timeout, TimeUnit timeUnit, Class<E> exceptionType) throws E extends Exception
E extends Exceptionpublic static <V> CompletableFuture<V> firstCompletedFuture(Iterable<? extends CompletionStage<? extends V>> futures)
public static <V> CompletableFuture<V> firstCompletedFuture(Iterable<? extends CompletionStage<? extends V>> futures, boolean propagateCancel)
public static <V> CompletableFuture<List<V>> allAsList(List<CompletableFuture<? extends V>> futures)
public static <T> CompletableFuture<T> addTimeout(CompletableFuture<T> future, MoreFutures.ValueSupplier<T> onTimeout, Duration timeout, ScheduledExecutorService executorService)
public static <V> CompletableFuture<V> toCompletableFuture(com.google.common.util.concurrent.ListenableFuture<V> listenableFuture)
public static <V> com.google.common.util.concurrent.ListenableFuture<V> toListenableFuture(CompletableFuture<V> completableFuture)
Copyright © 2010-2016 Airlift. All Rights Reserved.