Class ListenableFutureAdapter<T,S>
- java.lang.Object
- org.springframework.util.concurrent.FutureAdapter<T,S>
- org.springframework.util.concurrent.ListenableFutureAdapter<T,S>
- Type Parameters:
T
- the type of thisFuture
S
- the type of the adaptee'sFuture
- All Implemented Interfaces:
Future<T>
,ListenableFuture<T>
public abstract class ListenableFutureAdapter<T,S> extends FutureAdapter<T,S> implements ListenableFuture<T>
Abstract class that adapts aListenableFuture
parameterized over S into aListenableFuture
parameterized over T. All methods are delegated to the adaptee, whereFutureAdapter.get()
,FutureAdapter.get(long, java.util.concurrent.TimeUnit)
, andSuccessCallback.onSuccess(Object)
callFutureAdapter.adapt(Object)
on the adaptee's result.- Since:
- 4.0
- Author:
- Arjen Poutsma
Constructor Summary
Constructors Modifier Constructor Description protected
ListenableFutureAdapter(ListenableFuture<S> adaptee)
Construct a newListenableFutureAdapter
with the given adaptee.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCallback(ListenableFutureCallback<? super T> callback)
Register the givenListenableFutureCallback
.void
addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback)
Java 8 lambda-friendly alternative with success and failure callbacks.Methods inherited from class org.springframework.util.concurrent.FutureAdapter
adapt, cancel, get, get, getAdaptee, isCancelled, isDone
Constructor Detail
ListenableFutureAdapter
protected ListenableFutureAdapter(ListenableFuture<S> adaptee)
Construct a newListenableFutureAdapter
with the given adaptee.- Parameters:
adaptee
- the future to adapt to
Method Detail
addCallback
public void addCallback(ListenableFutureCallback<? super T> callback)
Description copied from interface:ListenableFuture
Register the givenListenableFutureCallback
.- Specified by:
addCallback
in interfaceListenableFuture<T>
- Parameters:
callback
- the callback to register
addCallback
public void addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback)
Description copied from interface:ListenableFuture
Java 8 lambda-friendly alternative with success and failure callbacks.- Specified by:
addCallback
in interfaceListenableFuture<T>
- Parameters:
successCallback
- the success callbackfailureCallback
- the failure callback