Package org.hawaiiframework.web.resource
Class ObjectErrorResourceAssembler
java.lang.Object
org.hawaiiframework.converter.AbstractModelConverter<org.springframework.validation.ObjectError,ValidationErrorResource>
org.hawaiiframework.web.resource.ObjectErrorResourceAssembler
- All Implemented Interfaces:
ModelConverter<org.springframework.validation.ObjectError,
ValidationErrorResource>
public class ObjectErrorResourceAssembler
extends AbstractModelConverter<org.springframework.validation.ObjectError,ValidationErrorResource>
- Since:
- 2.0.0
-
Constructor Summary
ConstructorDescriptionObjectErrorResourceAssembler
(com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionvoid
convert
(org.springframework.validation.ObjectError objectError, ValidationErrorResource resource) Converts the given source object into the target object.protected String
convertProperty
(String propertyName) Converts the given property name (field name or error code) using the application definedPropertyNamingStrategy
for consistent output in responses.Methods inherited from class org.hawaiiframework.converter.AbstractModelConverter
convert, convert, instantiateTargetObject
-
Constructor Details
-
ObjectErrorResourceAssembler
public ObjectErrorResourceAssembler(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
convert
public void convert(org.springframework.validation.ObjectError objectError, ValidationErrorResource resource) Description copied from interface:ModelConverter
Converts the given source object into the target object.- Parameters:
objectError
- the source objectresource
- the target object
-
convertProperty
Converts the given property name (field name or error code) using the application definedPropertyNamingStrategy
for consistent output in responses. The naming strategy is defined inapplication.yml
via thespring.jackson.property-naming-strategy
property.For example, if the
PropertyNamingStrategies.SnakeCaseStrategy
is defined, the following field names and error codes will be translated as following:- description -> description
- price -> price
- discountPrice -> discount_price
- Required -> required
- InvalidLength -> invalid_length
-