Package de.odrotbohm.spring.web.model
Interface MappedPayloads
public interface MappedPayloads
A monadic type to implement Spring MVC handler methods in a functional way.
- Author:
- Oliver Drotbohm
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic classA monadic type to work with a mapped payload alongsideErrorsto build up pipelines to eventually result in anHttpEntitybased on the processing steps. -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic <T> MappedPayloads.MappedPayload<T>Creates a newMappedPayloads.MappedPayloadof the given source andErrors.static MappedPayloads.MappedErrorsof(org.springframework.validation.Errors errors) Creates a newMappedPayloads.MappedErrorsfrom the givenErrorsinstance.static <T> MappedPayloads.MappedPayload<T>of(T payload, org.springframework.validation.Errors errors) Creates a newMappedPayloads.MappedPayloadfor the given source instancestatic org.springframework.http.ResponseEntity<?>toBadRequest(org.springframework.validation.Errors errors) Syntactic sugar to easily create aHttpStatus.BAD_REQUESTresponse from anErrorsinstance in aStreammapping step or the like.
-
Method Details
-
of
Creates a newMappedPayloads.MappedErrorsfrom the givenErrorsinstance.- 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 newMappedPayloads.MappedPayloadfor 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 newMappedPayloads.MappedPayloadof the given source andErrors. Of the source is empty, aHttpStatus.NOT_FOUNDwill 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 aHttpStatus.BAD_REQUESTresponse from anErrorsinstance in aStreammapping step or the like.- Parameters:
errors- must not be null.- Returns:
- will never be null.
-