Class AnnotationUtil
java.lang.Object
in.co.akshitbansal.springwebquery.util.AnnotationUtil
Utility methods for resolving query-related annotations from controller metadata
and validating
FieldMapping declarations.-
Constructor Summary
ConstructorsConstructorDescriptionAnnotationUtil(Set<? extends RsqlCustomOperator<?>> customOperators) Creates an annotation utility backed by registered custom operator instances. -
Method Summary
Modifier and TypeMethodDescriptionresolveWebQueryFromParameter(@NonNull org.springframework.core.MethodParameter parameter) ResolvesWebQueryfrom the controller method that declares the provided Spring MVC method parameter.voidvalidateFieldMappings(@NonNull FieldMapping[] fieldMappings) ValidatesFieldMappingdefinitions declared inWebQuery.voidvalidateFilterableField(@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 itsRsqlFilterabledeclaration(s).
-
Constructor Details
-
AnnotationUtil
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) ResolvesWebQueryfrom the controller method that declares the provided Spring MVC method parameter.- Parameters:
parameter- controller method parameter currently being resolved- Returns:
- resolved
WebQueryannotation - Throws:
QueryConfigurationException- if the method cannot be resolved or is not annotated withWebQuery
-
validateFieldMappings
ValidatesFieldMappingdefinitions declared inWebQuery.Validation rules:
- Alias names must be unique (
FieldMapping.name()). - Target entity fields must be unique (
FieldMapping.field()).
- Parameters:
fieldMappings- field mappings to validate- Throws:
QueryConfigurationException- if duplicate aliases or duplicate target fields are found
- Alias names must be unique (
-
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 itsRsqlFilterabledeclaration(s).- Parameters:
field- field being targeted by the request selectoroperator- comparison operator requested in the queryfieldPath- original selector path from the request- Throws:
QueryFieldValidationException- if the field is not filterableQueryForbiddenOperatorException- if the operator is not allowed for the field
-