Interface MappedPayloads


public interface MappedPayloads
A monadic type to implement Spring MVC handler methods in a functional way.
Author:
Oliver Drotbohm
  • Method Details

    • of

      static MappedPayloads.MappedErrors of(org.springframework.validation.Errors errors)
      Creates a new MappedPayloads.MappedErrors from the given Errors instance.
      Parameters:
      errors - must not be null.
      Returns:
      will never be null.
    • of

      static <T> MappedPayloads.MappedPayload<T> of(@Nullable T payload, org.springframework.validation.Errors errors)
      Creates a new MappedPayloads.MappedPayload for the given source instance
      Type Parameters:
      T -
      Parameters:
      payload - can be null.
      errors -
      Returns:
    • of

      static <T> MappedPayloads.MappedPayload<T> of(Optional<T> source, org.springframework.validation.Errors errors)
      Creates a new MappedPayloads.MappedPayload of the given source and Errors. Of the source is empty, a HttpStatus.NOT_FOUND will be produced independent of the built up pipeline.
      Type Parameters:
      T -
      Parameters:
      source - must not be null.
      errors - must not be null.
      Returns:
    • toBadRequest

      static org.springframework.http.ResponseEntity<?> toBadRequest(org.springframework.validation.Errors errors)
      Syntactic sugar to easily create a HttpStatus.BAD_REQUEST response from an Errors instance in a Stream mapping step or the like.
      Parameters:
      errors - must not be null.
      Returns:
      will never be null.