T
- the type of this Future
S
- the type of the adaptee's Future
public abstract class ListenableFutureAdapter<T,S> extends FutureAdapter<T,S> implements ListenableFuture<T>
ListenableFuture
parameterized over S into a
ListenableFuture
parameterized over T. All methods are delegated to the
adaptee, where FutureAdapter.get()
, FutureAdapter.get(long, java.util.concurrent.TimeUnit)
, and
SuccessCallback.onSuccess(Object)
call FutureAdapter.adapt(Object)
on the
adaptee's result.Modifier | Constructor and Description |
---|---|
protected |
ListenableFutureAdapter(ListenableFuture<S> adaptee)
Constructs a new
ListenableFutureAdapter with the given adaptee. |
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 . |
adapt, cancel, get, get, getAdaptee, isCancelled, isDone
protected ListenableFutureAdapter(ListenableFuture<S> adaptee)
ListenableFutureAdapter
with the given adaptee.adaptee
- the future to adaptee topublic void addCallback(ListenableFutureCallback<? super T> callback)
ListenableFuture
ListenableFuture
. 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)
ListenableFuture
ListenableFuture
.
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