Class EntityAwareFieldResolver

java.lang.Object
in.co.akshitbansal.springwebquery.resolver.EntityAwareFieldResolver
All Implemented Interfaces:
FieldResolver

public class EntityAwareFieldResolver extends Object implements FieldResolver
FieldResolver implementation that resolves selectors directly against an entity model, with optional alias support via FieldMapping.

This resolver can rewrite request selectors using declared aliases, reject access to original field names when a mapping forbids them, and validate the resolved terminal entity field via the supplied callback.

  • Constructor Details

    • EntityAwareFieldResolver

      public EntityAwareFieldResolver(Class<?> entityClass, FieldMapping[] fieldMappings)
      Creates an entity-aware resolver from raw field-mapping declarations.

      The supplied mappings are normalized into immutable lookup maps keyed by alias name and original entity field path so callers do not need to precompute resolver-specific structures.

      Parameters:
      entityClass - entity type used for path resolution
      fieldMappings - declared alias mappings from the public API contract
  • Method Details

    • resolvePathAndValidateTerminalField

      public String resolvePathAndValidateTerminalField(String reqFieldPath, Consumer<Field> terminalFieldValidator)
      Resolves an entity-facing selector path, validates the resolved terminal field, and returns the final entity path.
      Specified by:
      resolvePathAndValidateTerminalField in interface FieldResolver
      Parameters:
      reqFieldPath - selector path from the incoming request
      terminalFieldValidator - callback used to validate the resolved terminal field
      Returns:
      resolved entity path after alias translation
      Throws:
      QueryFieldValidationException - if the request path is blocked by mapping rules or cannot be resolved against the entity type