Package dev.morphia.query.validation
Class TypeValidator
- java.lang.Object
-
- dev.morphia.query.validation.TypeValidator
-
- All Implemented Interfaces:
Validator
- Direct Known Subclasses:
DefaultTypeValidator
,DoubleTypeValidator
,EntityAnnotatedValueValidator
,IntegerTypeValidator
,LongTypeValidator
public abstract class TypeValidator extends java.lang.Object implements Validator
Extend this class to provide specific validation for field types for query validation.
-
-
Constructor Summary
Constructors Constructor Description TypeValidator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract boolean
appliesTo(java.lang.Class<?> type)
Used by apply to figure out whether to apply the validation or simply return.boolean
apply(java.lang.Class<?> type, java.lang.Object value, java.util.List<ValidationFailure> validationFailures)
Apply validation for the given field.protected abstract void
validate(java.lang.Class<?> type, java.lang.Object value, java.util.List<ValidationFailure> validationFailures)
-
-
-
Method Detail
-
apply
public boolean apply(java.lang.Class<?> type, java.lang.Object value, java.util.List<ValidationFailure> validationFailures)
Apply validation for the given field. If the field is not of a type in the list returned by getTypeClasses, the validation is not applied and this method returns false. If the type is in the list, then the validate method is called to see if the value is of a type that can be applied to the given field type. Errors are appended to the validationFailures list.- Parameters:
type
- the Class of the field being queriedvalue
- the value being used for a queryvalidationFailures
- the list to add any failures to. If validation passes orappliesTo
returned false, this list will not change.- Returns:
- true if validation was applied, false if this validation doesn't apply to this field type.
-
appliesTo
protected abstract boolean appliesTo(java.lang.Class<?> type)
Used by apply to figure out whether to apply the validation or simply return.- Parameters:
type
- the type to be validated- Returns:
- true if this validator applies to this type, false otherwise
-
validate
protected abstract void validate(java.lang.Class<?> type, java.lang.Object value, java.util.List<ValidationFailure> validationFailures)
-
-