Package org.cyclos.impl.utils.validation
Class Validator
- java.lang.Object
-
- org.cyclos.impl.utils.validation.Validator
-
public class Validator extends Object
Utility class that validates an object
-
-
Constructor Summary
Constructors Constructor Description Validator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanappendPropertyValidations(RestBeanPropertyMapping restMapping, FormatterImpl formatter, ValidationResult validation, Property property, Object object)Append the validation errors for the given property, returning true when there's at least one errorprotected booleanappendValidation(RestBeanPropertyMapping restMapping, FormatterImpl formatter, ValidationResult validation, Object object)Appends all validation errors on the givenValidationResultfor the given object being validated, returning true when there's at least one error appendedPropertycustomField(CustomField<?,?,?> field, String valuesProperty, CustomFieldValueHandler customFieldValueHandler)Adds a custom field validation using the specified values propertyPropertycustomField(CustomField<?,?,?> field, CustomFieldValueHandler customFieldValueHandler)Adds a custom field validationValidatorgeneral(GeneralValidation generalValidation)Adds a general validationCollection<GeneralValidation>getGeneralValidations()StringgetPropertyNamePrefix()booleanhasPropertyValidationFor(CustomField<?,?,?> field)booleanhasValidationFor(com.querydsl.core.types.Path<?> path)booleanhasValidationFor(Property<?,?> property)Validatornested(PropertyAccess propertyAccess, Validator validator)Adds a nested validator for the bean retrieved through the given property access.Validatornested(Property<?,?> property, Validator validator)Adds a nested validator for the bean retrieved through the given list property validating all elements in the listPropertyproperty(com.querydsl.core.types.Path<?> path, NamedEntity label)Adds a bean property validation, or, if already added, returns the previous onePropertyproperty(com.querydsl.core.types.Path<?> path, MessageKey key)Adds a bean property validation, or, if already added, returns the previous onePropertyproperty(com.querydsl.core.types.Path<?> path, TranslationMessageSpecification message)Adds a bean property validation, or, if already added, returns the previous onePropertyproperty(PropertyAccess propertyAccess, String label)Propertyproperty(PropertyAccess propertyAccess, Supplier<Object> displaySupplier)Propertyproperty(PropertyAccess propertyAccess, NamedEntity label)Adds a property validation that uses the given property access to reach it.Propertyproperty(PropertyAccess propertyAccess, MessageKey key)Adds a property validation that uses the given property access to reach it.Propertyproperty(PropertyAccess propertyAccess, TranslationMessageSpecification message)Adds a property validation that uses the given property access to reach it.Propertyproperty(Property<?,?> property, String label)Propertyproperty(Property<?,?> property, NamedEntity label)Adds a bean property validation, or, if already added, returns the previous onePropertyproperty(Property<?,?> property, MessageKey key)Adds a bean property validation, or, if already added, returns the previous onePropertyproperty(Property<?,?> property, TranslationMessageSpecification message)Adds a bean property validation, or, if already added, returns the previous oneprotected PropertypropertyInternal(PropertyAccess propertyAccess, Object display)Adds a property validation that uses the given property access to reach it.protected StringresolveDisplayName(FormatterImpl formatter, Property property, Object object)Returns the display name of a given propertyprotected StringresolveGeneralMessage(FormatterImpl formatter, ValidationError error)Returns the translation message for a given general errorprotected StringresolvePropertyMessage(FormatterImpl formatter, String displayName, ValidationError error)Returns the translation message for a given property errorvoidsetPropertyNamePrefix(String propertyNamePrefix)voidvalidate(RestBeanPropertyMapping restMapping, FormatterImpl formatter, Object object)Validates the given object, either throwing aValidationExceptionor returning silently
-
-
-
Method Detail
-
customField
public Property customField(CustomField<?,?,?> field, CustomFieldValueHandler customFieldValueHandler)
Adds a custom field validation
-
customField
public Property customField(CustomField<?,?,?> field, String valuesProperty, CustomFieldValueHandler customFieldValueHandler)
Adds a custom field validation using the specified values property
-
general
public Validator general(GeneralValidation generalValidation)
Adds a general validation
-
getGeneralValidations
public Collection<GeneralValidation> getGeneralValidations()
-
getPropertyNamePrefix
public String getPropertyNamePrefix()
-
hasPropertyValidationFor
public boolean hasPropertyValidationFor(CustomField<?,?,?> field)
- Returns:
- true if this validator already has some property validation for the specified custom field.
-
hasValidationFor
public boolean hasValidationFor(Property<?,?> property)
- Returns:
- true if this validator already has some property validation for the specified property bean.
-
hasValidationFor
public boolean hasValidationFor(com.querydsl.core.types.Path<?> path)
- Returns:
- true if this validator already has some property validation for the specified entity path.
-
nested
public Validator nested(Property<?,?> property, Validator validator)
Adds a nested validator for the bean retrieved through the given list property validating all elements in the list
-
nested
public Validator nested(PropertyAccess propertyAccess, Validator validator)
Adds a nested validator for the bean retrieved through the given property access. When the value is a collection, validates all elements in it
-
property
public Property property(Property<?,?> property, MessageKey key)
Adds a bean property validation, or, if already added, returns the previous one
-
property
public Property property(Property<?,?> property, NamedEntity label)
Adds a bean property validation, or, if already added, returns the previous one
-
property
public Property property(Property<?,?> property, TranslationMessageSpecification message)
Adds a bean property validation, or, if already added, returns the previous one
-
property
public Property property(com.querydsl.core.types.Path<?> path, MessageKey key)
Adds a bean property validation, or, if already added, returns the previous one
-
property
public Property property(com.querydsl.core.types.Path<?> path, NamedEntity label)
Adds a bean property validation, or, if already added, returns the previous one
-
property
public Property property(com.querydsl.core.types.Path<?> path, TranslationMessageSpecification message)
Adds a bean property validation, or, if already added, returns the previous one
-
property
public Property property(PropertyAccess propertyAccess, MessageKey key)
Adds a property validation that uses the given property access to reach it.
-
property
public Property property(PropertyAccess propertyAccess, NamedEntity label)
Adds a property validation that uses the given property access to reach it.
-
property
public Property property(PropertyAccess propertyAccess, String label)
-
property
public Property property(PropertyAccess propertyAccess, Supplier<Object> displaySupplier)
-
property
public Property property(PropertyAccess propertyAccess, TranslationMessageSpecification message)
Adds a property validation that uses the given property access to reach it.
-
setPropertyNamePrefix
public void setPropertyNamePrefix(String propertyNamePrefix)
-
validate
public void validate(RestBeanPropertyMapping restMapping, FormatterImpl formatter, Object object) throws ValidationException
Validates the given object, either throwing aValidationExceptionor returning silently- Throws:
ValidationException
-
appendPropertyValidations
protected boolean appendPropertyValidations(RestBeanPropertyMapping restMapping, FormatterImpl formatter, ValidationResult validation, Property property, Object object)
Append the validation errors for the given property, returning true when there's at least one error
-
appendValidation
protected boolean appendValidation(RestBeanPropertyMapping restMapping, FormatterImpl formatter, ValidationResult validation, Object object)
Appends all validation errors on the givenValidationResultfor the given object being validated, returning true when there's at least one error appended
-
propertyInternal
protected Property propertyInternal(PropertyAccess propertyAccess, Object display)
Adds a property validation that uses the given property access to reach it.
-
resolveDisplayName
protected String resolveDisplayName(FormatterImpl formatter, Property property, Object object)
Returns the display name of a given property
-
resolveGeneralMessage
protected String resolveGeneralMessage(FormatterImpl formatter, ValidationError error)
Returns the translation message for a given general error
-
resolvePropertyMessage
protected String resolvePropertyMessage(FormatterImpl formatter, String displayName, ValidationError error)
Returns the translation message for a given property error
-
-