T
- the result type returned by this Future's get
methodpublic 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) |
CompletableFuture<T> |
completable()
Expose this
ListenableFuture as a JDK CompletableFuture . |
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)
ListenableFuture
ListenableFutureCallback
.addCallback
in interface ListenableFuture<T>
callback
- the callback to registerpublic void addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback)
ListenableFuture
addCallback
in interface ListenableFuture<T>
successCallback
- the success callbackfailureCallback
- the failure callbackpublic CompletableFuture<T> completable()
ListenableFuture
ListenableFuture
as a JDK CompletableFuture
.completable
in interface ListenableFuture<T>
public boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
isCancelled
in interface Future<T>
public T get() throws InterruptedException, ExecutionException
get
in interface Future<T>
InterruptedException
ExecutionException
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get
in interface Future<T>
InterruptedException
ExecutionException
TimeoutException