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 thisFutureS- 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 a
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.- Since:
- 4.0
- Author:
- Arjen Poutsma
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedListenableFutureAdapter(ListenableFuture<S> adaptee) Construct a newListenableFutureAdapterwith the given adaptee. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCallback(ListenableFutureCallback<? super T> callback) Register the givenListenableFutureCallback.voidaddCallback(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, isDoneMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.util.concurrent.ListenableFuture
completable
-
Constructor Details
-
ListenableFutureAdapter
Construct a newListenableFutureAdapterwith the given adaptee.- Parameters:
adaptee- the future to adapt to
-
-
Method Details
-
addCallback
Description copied from interface:ListenableFutureRegister the givenListenableFutureCallback.- Specified by:
addCallbackin interfaceListenableFuture<T>- Parameters:
callback- the callback to register
-
addCallback
public void addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback) Description copied from interface:ListenableFutureJava 8 lambda-friendly alternative with success and failure callbacks.- Specified by:
addCallbackin interfaceListenableFuture<T>- Parameters:
successCallback- the success callbackfailureCallback- the failure callback
-