Class DTOValidationRSQLVisitor
java.lang.Object
in.co.akshitbansal.springwebquery.ValidationRSQLVisitor
in.co.akshitbansal.springwebquery.DTOValidationRSQLVisitor
- All Implemented Interfaces:
cz.jirutka.rsql.parser.ast.RSQLVisitor<Void,NodeMetadata>
RSQL AST visitor that validates filters against a DTO contract and maps DTO
property paths to entity property paths.
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 Summary
ConstructorsConstructorDescriptionDTOValidationRSQLVisitor(Class<?> entityClass, Class<?> dtoClass, AnnotationUtil annotationUtil, boolean andNodeAllowed, boolean orNodeAllowed, int maxDepth) Creates a DTO-aware validation visitor. -
Method Summary
Modifier and TypeMethodDescriptionReturns immutable selector mappings generated while visiting nodes.protected voidvalidateComparisonNode(cz.jirutka.rsql.parser.ast.ComparisonNode node) Validates a single comparison expression and records DTO-to-entity mapping.Methods inherited from class in.co.akshitbansal.springwebquery.ValidationRSQLVisitor
validateNode, visit, visit, visit
-
Constructor Details
-
DTOValidationRSQLVisitor
public DTOValidationRSQLVisitor(Class<?> entityClass, Class<?> dtoClass, AnnotationUtil annotationUtil, boolean andNodeAllowed, boolean orNodeAllowed, int maxDepth) Creates a DTO-aware validation visitor.- Parameters:
entityClass- target entity type used for final path validationdtoClass- DTO type used to validate incoming selector pathsannotationUtil- helper for resolving allowed operators from annotationsandNodeAllowed- whether logical AND operator is allowedorNodeAllowed- whether logical OR operator is allowedmaxDepth- maximum allowed depth for the RSQL AST
-
-
Method Details
-
getFieldMappings
Returns immutable selector mappings generated while visiting nodes.- Returns:
- map from request DTO path to resolved entity path
-
validateComparisonNode
protected void validateComparisonNode(cz.jirutka.rsql.parser.ast.ComparisonNode node) Validates a single comparison expression and records DTO-to-entity mapping.- Specified by:
validateComparisonNodein classValidationRSQLVisitor- Parameters:
node- node to validate
-