public class HandlerResult
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private BindingContext |
bindingContext |
private java.util.function.Function<java.lang.Throwable,<any>> |
exceptionHandler |
private java.lang.Object |
handler |
private ResolvableType |
returnType |
private java.lang.Object |
returnValue |
Constructor and Description |
---|
HandlerResult(java.lang.Object handler,
java.lang.Object returnValue,
MethodParameter returnType)
Create a new
HandlerResult . |
HandlerResult(java.lang.Object handler,
java.lang.Object returnValue,
MethodParameter returnType,
BindingContext context)
Create a new
HandlerResult . |
Modifier and Type | Method and Description |
---|---|
<any> |
applyExceptionHandler(java.lang.Throwable failure)
Apply the exception handler and return the alternative result.
|
BindingContext |
getBindingContext()
Return the BindingContext used for request handling.
|
java.lang.Object |
getHandler()
Return the handler that handled the request.
|
Model |
getModel()
Return the model used for request handling.
|
ResolvableType |
getReturnType()
Return the type of the value returned from the handler.
|
MethodParameter |
getReturnTypeSource()
Return the
MethodParameter from which
returnType was created. |
java.util.Optional<java.lang.Object> |
getReturnValue()
Return the value returned from the handler wrapped as
Optional . |
boolean |
hasExceptionHandler()
Whether there is an exception handler.
|
HandlerResult |
setExceptionHandler(java.util.function.Function<java.lang.Throwable,<any>> function)
Configure an exception handler that may be used to produce an alternative
result when result handling fails.
|
private final java.lang.Object handler
private final java.lang.Object returnValue
private final ResolvableType returnType
private final BindingContext bindingContext
private java.util.function.Function<java.lang.Throwable,<any>> exceptionHandler
public HandlerResult(java.lang.Object handler, java.lang.Object returnValue, MethodParameter returnType)
HandlerResult
.handler
- the handler that handled the requestreturnValue
- the return value from the handler possibly null
returnType
- the return value typepublic HandlerResult(java.lang.Object handler, java.lang.Object returnValue, MethodParameter returnType, BindingContext context)
HandlerResult
.handler
- the handler that handled the requestreturnValue
- the return value from the handler possibly null
returnType
- the return value typecontext
- the binding context used for request handlingpublic java.lang.Object getHandler()
public java.util.Optional<java.lang.Object> getReturnValue()
Optional
.public ResolvableType getReturnType()
public MethodParameter getReturnTypeSource()
MethodParameter
from which
returnType
was created.public BindingContext getBindingContext()
public Model getModel()
getBindingContext().getModel()
.public HandlerResult setExceptionHandler(java.util.function.Function<java.lang.Throwable,<any>> function)
function
- the error handlerpublic boolean hasExceptionHandler()
public <any> applyExceptionHandler(java.lang.Throwable failure)
failure
- the exception