Class DTOValidationRSQLVisitor

java.lang.Object
in.co.akshitbansal.springwebquery.ast.AbstractValidationRSQLVisitor
in.co.akshitbansal.springwebquery.ast.DTOValidationRSQLVisitor
All Implemented Interfaces:
cz.jirutka.rsql.parser.ast.RSQLVisitor<Void,NodeMetadata>

public class DTOValidationRSQLVisitor extends AbstractValidationRSQLVisitor
RSQL AST visitor that validates filters against a DTO contract and maps DTO property paths to entity property paths via a shared FieldResolver contract.

This visitor is used when WebQuery.dtoClass() is configured. It enforces that:

  • The requested selector exists on the DTO type.
  • The terminal DTO field is annotated with RSQLFilterable.
  • The requested operator is allowed for that DTO field.
  • The resulting mapped entity path can be resolved on the configured entity type.

During validation, selector mappings are captured and exposed via getFieldMappings() so downstream query construction can apply DTO-to-entity path translation.

  • Constructor Details

    • DTOValidationRSQLVisitor

      public DTOValidationRSQLVisitor(FieldResolver fieldResolver, FilterableFieldValidator filterableFieldValidator, boolean andNodeAllowed, boolean orNodeAllowed, int maxDepth)
      Creates a DTO-aware validation visitor.
      Parameters:
      fieldResolver - resolver that validates DTO selectors and maps them to entity paths
      filterableFieldValidator - validator used to enforce RSQLFilterable constraints
      andNodeAllowed - whether logical AND operator is allowed
      orNodeAllowed - whether logical OR operator is allowed
      maxDepth - maximum allowed depth for the RSQL AST
  • Method Details

    • getFieldMappings

      public Map<String,String> getFieldMappings()
      Returns immutable selector mappings generated while visiting nodes.
      Returns:
      map from request DTO path to resolved entity path collected so far
    • validateComparisonNode

      protected void validateComparisonNode(cz.jirutka.rsql.parser.ast.ComparisonNode node)
      Validates a single comparison expression and records DTO-to-entity mapping.
      Specified by:
      validateComparisonNode in class AbstractValidationRSQLVisitor
      Parameters:
      node - node to validate