Class AnnotationUtil

java.lang.Object
in.co.akshitbansal.springwebquery.util.AnnotationUtil

public class AnnotationUtil extends Object
Utility methods for resolving query-related annotations from controller metadata and validating FieldMapping declarations.
  • Constructor Details

    • AnnotationUtil

      public AnnotationUtil(Set<? extends RsqlCustomOperator<?>> customOperators)
      Creates an annotation utility backed by registered custom operator instances.
      Parameters:
      customOperators - custom operators available to annotation-driven validation
  • Method Details

    • resolveWebQueryFromParameter

      public WebQuery resolveWebQueryFromParameter(@NonNull @NonNull org.springframework.core.MethodParameter parameter)
      Resolves WebQuery from the controller method that declares the provided Spring MVC method parameter.
      Parameters:
      parameter - controller method parameter currently being resolved
      Returns:
      resolved WebQuery annotation
      Throws:
      QueryConfigurationException - if the method cannot be resolved or is not annotated with WebQuery
    • validateFieldMappings

      public void validateFieldMappings(@NonNull @NonNull FieldMapping[] fieldMappings)
      Validates FieldMapping definitions declared in WebQuery.

      Validation rules:

      Parameters:
      fieldMappings - field mappings to validate
      Throws:
      QueryConfigurationException - if duplicate aliases or duplicate target fields are found
    • validateFilterableField

      public void validateFilterableField(@NonNull @NonNull Field field, cz.jirutka.rsql.parser.ast.ComparisonOperator operator, String fieldPath)
      Validates that a field is marked as filterable and that the requested operator is permitted by its RsqlFilterable declaration(s).
      Parameters:
      field - field being targeted by the request selector
      operator - comparison operator requested in the query
      fieldPath - original selector path from the request
      Throws:
      QueryFieldValidationException - if the field is not filterable
      QueryForbiddenOperatorException - if the operator is not allowed for the field