Class FieldResolvingUtil
java.lang.Object
in.co.akshitbansal.springwebquery.util.FieldResolvingUtil
Shared field/path resolution helpers used by DTO-aware and entity-aware
query validation flows.
This utility centralizes:
- DTO selector path resolution and DTO-to-entity path translation.
- Entity selector resolution with
FieldMappingalias handling. - Terminal field validation hooks supplied by callers.
Methods throw library-specific query exceptions so resolver and visitor layers can surface consistent validation/configuration errors.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildEntityPathFromDtoPath(Class<?> entityClass, Class<?> dtoClass, String dtoPath, Consumer<Field> terminalFieldValidator) Resolves a DTO selector path, validates its terminal DTO field, maps it to an entity path, and validates that the mapped path exists on the entity.static StringresolveEntityPath(Class<?> entityClass, String reqFieldPath, Map<String, FieldMapping> fieldMappingMap, Map<String, FieldMapping> originalFieldNameMap, Consumer<Field> terminalFieldValidator) Resolves an incoming entity-aware selector path by applying configuredFieldMappingaliases and validating the resolved terminal field.
-
Method Details
-
buildEntityPathFromDtoPath
public static String buildEntityPathFromDtoPath(Class<?> entityClass, Class<?> dtoClass, String dtoPath, Consumer<Field> terminalFieldValidator) Resolves a DTO selector path, validates its terminal DTO field, maps it to an entity path, and validates that the mapped path exists on the entity.- Parameters:
entityClass- entity type used to validate mapped path existencedtoClass- DTO type used to resolve incoming selector pathdtoPath- incoming selector path from requestterminalFieldValidator- validation callback for the terminal DTO field- Returns:
- mapped entity path corresponding to
dtoPath - Throws:
QueryFieldValidationException- if the DTO selector cannot be resolvedQueryConfigurationException- if the mapped entity path cannot be resolved
-
resolveEntityPath
public static String resolveEntityPath(Class<?> entityClass, String reqFieldPath, Map<String, FieldMapping> fieldMappingMap, Map<String, FieldMapping> originalFieldNameMap, Consumer<Field> terminalFieldValidator) Resolves an incoming entity-aware selector path by applying configuredFieldMappingaliases and validating the resolved terminal field.- Parameters:
entityClass- entity type used for path resolutionreqFieldPath- incoming selector path from requestfieldMappingMap- mappings keyed by alias nameoriginalFieldNameMap- mappings keyed by original entity field pathterminalFieldValidator- validation callback for the resolved terminal field- Returns:
- resolved entity field path after alias substitution
- Throws:
QueryFieldValidationException- if the selector is disallowed or cannot be resolved
-