Class TypeValidator

    • 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TypeValidator

        public TypeValidator()
    • 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 queried
        value - the value being used for a query
        validationFailures - the list to add any failures to. If validation passes or appliesTo 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)