Class ResultHandlerMethodReturnValueHandler

java.lang.Object
dmx.fun.spring.boot.web.ResultHandlerMethodReturnValueHandler
All Implemented Interfaces:
org.springframework.web.method.support.HandlerMethodReturnValueHandler

@NullMarked public final class ResultHandlerMethodReturnValueHandler extends Object implements org.springframework.web.method.support.HandlerMethodReturnValueHandler
Spring MVC HandlerMethodReturnValueHandler for Result, Validated, and Try return values.

Maps successful outcomes to HTTP 200 and error outcomes to HTTP 500 while delegating body serialization to a standard body processor.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ResultHandlerMethodReturnValueHandler(org.springframework.web.method.support.HandlerMethodReturnValueHandler delegate)
    Creates a handler that unwraps Result, Validated, and Try return values and delegates serialization of the unwrapped value (or error) to the given handler.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    handleReturnValue(@Nullable Object returnValue, org.springframework.core.MethodParameter returnType, org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest webRequest)
     
    boolean
    supportsReturnType(org.springframework.core.MethodParameter returnType)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ResultHandlerMethodReturnValueHandler

      public ResultHandlerMethodReturnValueHandler(org.springframework.web.method.support.HandlerMethodReturnValueHandler delegate)
      Creates a handler that unwraps Result, Validated, and Try return values and delegates serialization of the unwrapped value (or error) to the given handler.
      Parameters:
      delegate - the handler that writes the response body — typically a RequestResponseBodyMethodProcessor
  • Method Details

    • supportsReturnType

      public boolean supportsReturnType(org.springframework.core.MethodParameter returnType)
      Specified by:
      supportsReturnType in interface org.springframework.web.method.support.HandlerMethodReturnValueHandler
    • handleReturnValue

      public void handleReturnValue(@Nullable Object returnValue, org.springframework.core.MethodParameter returnType, org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest webRequest) throws Exception
      Specified by:
      handleReturnValue in interface org.springframework.web.method.support.HandlerMethodReturnValueHandler
      Throws:
      Exception