Class FieldResolvingUtil

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

public class FieldResolvingUtil extends Object
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 FieldMapping alias 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 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 existence
      dtoClass - DTO type used to resolve incoming selector path
      dtoPath - incoming selector path from request
      terminalFieldValidator - validation callback for the terminal DTO field
      Returns:
      mapped entity path corresponding to dtoPath
      Throws:
      QueryFieldValidationException - if the DTO selector cannot be resolved
      QueryConfigurationException - 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 configured FieldMapping aliases and validating the resolved terminal field.
      Parameters:
      entityClass - entity type used for path resolution
      reqFieldPath - incoming selector path from request
      fieldMappingMap - mappings keyed by alias name
      originalFieldNameMap - mappings keyed by original entity field path
      terminalFieldValidator - 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