Class CompletableToListenableFutureAdapter<T>
java.lang.Object
org.springframework.util.concurrent.CompletableToListenableFutureAdapter<T>
- Type Parameters:
T- the result type returned by this Future'sgetmethod
- All Implemented Interfaces:
Future<T>,ListenableFuture<T>
- Direct Known Subclasses:
MonoToListenableFutureAdapter
- Since:
- 4.2
- Author:
- Sebastien Deleuze, Juergen Hoeller
-
Constructor Summary
ConstructorsConstructorDescriptionCompletableToListenableFutureAdapter(CompletableFuture<T> completableFuture) Create a new adapter for the givenCompletableFuture.CompletableToListenableFutureAdapter(CompletionStage<T> completionStage) Create a new adapter for the givenCompletionStage. -
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.booleancancel(boolean mayInterruptIfRunning) Expose thisListenableFutureas a JDKCompletableFuture.get()booleanbooleanisDone()
-
Constructor Details
-
CompletableToListenableFutureAdapter
Create a new adapter for the givenCompletionStage.- Since:
- 4.3.7
-
CompletableToListenableFutureAdapter
Create a new adapter for the givenCompletableFuture.
-
-
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
-
completable
Description copied from interface:ListenableFutureExpose thisListenableFutureas a JDKCompletableFuture.- Specified by:
completablein interfaceListenableFuture<T>
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) -
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfaceFuture<T>
-
isDone
public boolean isDone() -
get
- Specified by:
getin interfaceFuture<T>- Throws:
InterruptedExceptionExecutionException
-
get
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
getin interfaceFuture<T>- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-