Class OperationValidator

    • Constructor Detail

      • OperationValidator

        public OperationValidator()
    • Method Detail

      • apply

        public boolean apply​(MappedField mappedField,
                             FilterOperator operator,
                             java.lang.Object value,
                             java.util.List<ValidationFailure> validationFailures)
        Apply validation for the given operator. If the operator does not match the operator required by the implementing class, then this method will return false to show validation was not applied. If the operator is the one being validated, this method will return true, and any failures in validation will be added to the list of validationFailures.
        Parameters:
        mappedField - the field being queried
        operator - any FilterOperator for a query
        value - the query value, to apply the operator to
        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 operator.
      • getOperator

        protected abstract FilterOperator getOperator()
        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
        Returns:
        the FilterOperator this validator cares about.
      • validate

        protected abstract void validate​(MappedField mappedField,
                                         java.lang.Object value,
                                         java.util.List<ValidationFailure> validationFailures)
        Performs the actual validation, and assumes appliesTo has returned true
        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.