public class CompletableFutureReturnValueHandler extends AbstractAsyncReturnValueHandler
CompletableFuture
(and as of 4.3.7 also CompletionStage
)
as a return value type.Constructor and Description |
---|
CompletableFutureReturnValueHandler() |
Modifier and Type | Method and Description |
---|---|
boolean |
supportsReturnType(MethodParameter returnType)
Whether the given method return type is
supported by this handler.
|
ListenableFuture<?> |
toListenableFuture(Object returnValue,
MethodParameter returnType)
Adapt the asynchronous return value to a
ListenableFuture . |
handleReturnValue, isAsyncReturnValue
public boolean supportsReturnType(MethodParameter returnType)
HandlerMethodReturnValueHandler
returnType
- the method return type to checktrue
if this handler supports the supplied return type;
false
otherwisepublic ListenableFuture<?> toListenableFuture(Object returnValue, MethodParameter returnType)
AsyncHandlerMethodReturnValueHandler
ListenableFuture
.
Implementations should consider returning an instance of
SettableListenableFuture
. Return value handling will then continue when
the ListenableFuture is completed with either success or error.
Note: this method will only be invoked after
HandlerMethodReturnValueHandler.supportsReturnType(org.springframework.core.MethodParameter)
is called and it returns true
.
returnValue
- the value returned from the handler methodreturnType
- the type of the return valuenull
in which case
no further handling will be performed