public final class CompletableFutures extends Object
CompletableFuture.| Modifier and Type | Method and Description | 
|---|---|
static <T> CompletableFuture<T> | 
completedExceptionally(Throwable throwable)
Return an immediately exceptional completed CompletableFuture. 
 | 
static <V> com.google.common.util.concurrent.ListenableFuture<V> | 
toListenableFuture(CompletableFuture<V> completableFuture)
Converts a Java 8 CompletionStage to a Guava ListenableFuture. 
 | 
public static <V> com.google.common.util.concurrent.ListenableFuture<V> toListenableFuture(CompletableFuture<V> completableFuture)
CompletionStages.toListenableFuture(CompletionStage) for a related function.public static <T> CompletableFuture<T> completedExceptionally(Throwable throwable)
Inspired by Guava's Futures.immediateFailedFuture(Throwable).
 
 Useful because while CompletableFuture does have a
 CompletableFuture.completedFuture(Object) static factory method
 to obtain immediate non-exceptional value completion, it is missing a
 static factory method like this. This is often useful, e.g. when catching
 exceptions to transform into CompletableFuture to return, and saves the 3
 lines to create a new instance, invoke the non-static
 CompletableFuture.completeExceptionally(Throwable) and return the
 completableFuture. (It's not possible to use chained invocation style,
 because completeExceptionally does not return this but a boolean, which
 is useless when requiring an immediately completed CompletionStage.)
Copyright © 2019 OpenDaylight. All rights reserved.