@UsesJava8 public class CompletableToListenableFutureAdapter<T> extends Object implements ListenableFuture<T>
| Constructor and Description |
|---|
CompletableToListenableFutureAdapter(CompletableFuture<T> completableFuture)
Create a new adapter for the given
CompletableFuture. |
CompletableToListenableFutureAdapter(CompletionStage<T> completionStage)
Create a new adapter for the given
CompletionStage. |
| Modifier and Type | Method and Description |
|---|---|
void |
addCallback(ListenableFutureCallback<? super T> callback)
Register the given
ListenableFutureCallback. |
void |
addCallback(SuccessCallback<? super T> successCallback,
FailureCallback failureCallback)
Java 8 lambda-friendly alternative with success and failure callbacks.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
T |
get() |
T |
get(long timeout,
TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
public CompletableToListenableFutureAdapter(CompletionStage<T> completionStage)
CompletionStage.public CompletableToListenableFutureAdapter(CompletableFuture<T> completableFuture)
CompletableFuture.public void addCallback(ListenableFutureCallback<? super T> callback)
ListenableFutureListenableFutureCallback.addCallback in interface ListenableFuture<T>callback - the callback to registerpublic void addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback)
ListenableFutureaddCallback in interface ListenableFuture<T>successCallback - the success callbackfailureCallback - the failure callbackpublic boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
isCancelled in interface Future<T>public T get() throws InterruptedException, ExecutionException
get in interface Future<T>InterruptedExceptionExecutionExceptionpublic T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get in interface Future<T>InterruptedExceptionExecutionExceptionTimeoutException