Class AttributePathParser

java.lang.Object
dev.hogwai.dynamodb.simplified.internal.AttributePathParser

public final class AttributePathParser extends Object
Parses nested attribute paths like address.city and tags[0].name.

This is a shared utility extracted from the expression builder classes (FilterExpression, ProjectionExpression, UpdateExpression), which all contained identical parsing logic in their addNestedName() methods. Only the parsing is unified here; the reconstruction (generating #n0/{:v0} placeholders) differs per expression type and stays in each class.

  • Method Details

    • parse

      public static List<PathSegment> parse(String path)
      Parses a dot/bracket path into segments.

      Example: "tags[0].name" -> [("tags", "[0]"), ("name", null)]

      Parameters:
      path - the dotted attribute path
      Returns:
      ordered list of path segments
    • rebuildNestedPath

      public static String rebuildNestedPath(String path, UnaryOperator<String> nameResolver)
      Reconstructs a nested attribute path using a name resolver function.

      Each path segment is resolved via the name resolver, and index suffixes (e.g., [0]) are appended when present. Segments are joined with dots.

      Example: "tags[0].name" with resolver s -> "#n0" -> "#n0[0].\#p0"

      Parameters:
      path - the dotted attribute path
      nameResolver - function that resolves a segment name to a placeholder
      Returns:
      the reconstructed path string with resolved placeholders