Class SizeOperationValidator

  • All Implemented Interfaces:
    Validator

    public final class SizeOperationValidator
    extends OperationValidator
    Checks if the value can have the FilterOperator.ALL operator applied to it. Since this class does not need state, and the methods can't be static because it implements an interface, it seems to be one of the few places where the Singleton pattern seems appropriate.
    • Method Detail

      • getInstance

        public static SizeOperationValidator getInstance()
        Get the instance
        Returns:
        the Singleton instance of this validator
      • getOperator

        protected FilterOperator getOperator()
        Description copied from class: OperationValidator
        This method is called by the apply method to determine whether to validate the query. The validator will only work for a single FilterOperator, and this will be returned by this method
        Specified by:
        getOperator in class OperationValidator
        Returns:
        the FilterOperator this validator cares about.
      • validate

        protected void validate​(MappedField mappedField,
                                java.lang.Object value,
                                java.util.List<ValidationFailure> validationFailures)
        Description copied from class: OperationValidator
        Performs the actual validation, and assumes appliesTo has returned true
        Specified by:
        validate in class OperationValidator
        Parameters:
        mappedField - the field being queried
        value - the query value, to apply the operator to. This should not be null.
        validationFailures - the list to add any new ValidationFailures to. If validation passed this list will not change.