@UsesJava8 public class CompletableToListenableFutureAdapter<T> extends Object implements ListenableFuture<T>
CompletableFuture into a ListenableFuture.| Constructor and Description |
|---|
CompletableToListenableFutureAdapter(CompletableFuture<T> completableFuture) |
| Modifier and Type | Method and Description |
|---|---|
void |
addCallback(ListenableFutureCallback<? super T> callback)
Registers the given callback to this
ListenableFuture. |
void |
addCallback(SuccessCallback<? super T> successCallback,
FailureCallback failureCallback)
Registers the given success and failure callbacks to this
ListenableFuture. |
boolean |
cancel(boolean mayInterruptIfRunning) |
T |
get() |
T |
get(long timeout,
TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
public CompletableToListenableFutureAdapter(CompletableFuture<T> completableFuture)
public void addCallback(ListenableFutureCallback<? super T> callback)
ListenableFutureListenableFuture. The callback will
be triggered when this Future is complete or, if it is already complete,
immediately.addCallback in interface ListenableFuture<T>callback - the callback to registerpublic void addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback)
ListenableFutureListenableFuture.
The callback will be triggered when this Future is complete or, if it is
already complete immediately. This is a Java 8 lambdas compliant alternative to
ListenableFuture.addCallback(ListenableFutureCallback).addCallback in interface ListenableFuture<T>successCallback - the success callback to registerfailureCallback - the failure callback to registerpublic 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