S - the type of object expected from the PromiseT - the type of object expected from the ListenableFutureabstract class AbstractPromiseToListenableFutureAdapter<S,T> extends java.lang.Object implements ListenableFuture<T>
Promise to ListenableFuture optionally converting
the result Object type <S> to the expected target type <T>.| Modifier and Type | Field and Description |
|---|---|
private <any> |
promise |
private ListenableFutureCallbackRegistry<T> |
registry |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractPromiseToListenableFutureAdapter(<any> promise) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract T |
adapt(S result) |
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,
java.util.concurrent.TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
private final <any> promise
private final ListenableFutureCallbackRegistry<T> registry
protected AbstractPromiseToListenableFutureAdapter(<any> promise)
public T get() throws java.lang.InterruptedException
get in interface java.util.concurrent.Future<T>java.lang.InterruptedExceptionpublic T get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
get in interface java.util.concurrent.Future<T>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutExceptionpublic boolean cancel(boolean mayInterruptIfRunning)
cancel in interface java.util.concurrent.Future<T>public boolean isCancelled()
isCancelled in interface java.util.concurrent.Future<T>public boolean isDone()
isDone in interface java.util.concurrent.Future<T>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 register