Record Class FieldPath

java.lang.Object
java.lang.Record
dev.hardwood.metadata.FieldPath
Record Components:
elements - the path components from root to leaf

public record FieldPath(List<String> elements) extends Record

Path from the root schema to a leaf column, represented as a list of field names.

For flat schemas, the path has a single element (the column name). For nested schemas, it contains each intermediate group name (e.g. ["address", "zip"] for a zip field inside an address struct).

  • Constructor Summary

    Constructors
    Constructor
    Description
    FieldPath(List<String> elements)
    Creates an instance of a FieldPath record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the elements record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Whether this path is empty (has no elements) or not.
    Returns the leaf (last) element of the path.
    boolean
    Returns true if this path matches the given dotted name.
    static FieldPath
    of(String... elements)
    Creates a FieldPath from individual path components.
    Returns the first (top-level) element of the path.
    Returns the dot-separated string representation of this path.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FieldPath

      public FieldPath(List<String> elements)
      Creates an instance of a FieldPath record class.
      Parameters:
      elements - the value for the elements record component
  • Method Details

    • of

      public static FieldPath of(String... elements)
      Creates a FieldPath from individual path components.
    • leafName

      public String leafName()
      Returns the leaf (last) element of the path.
    • topLevelName

      public String topLevelName()
      Returns the first (top-level) element of the path.
    • matchesDottedName

      public boolean matchesDottedName(String dottedName)

      Returns true if this path matches the given dotted name.

      A dotted name like "address.zip" matches the path ["address", "zip"]. A prefix match is allowed: "address" matches ["address", "zip"] (useful for filtering on a top-level field that contains nested columns).

      Parameters:
      dottedName - a dot-separated field reference (e.g. "address.zip")
      Returns:
      true if this path matches the dotted name
    • toString

      public String toString()
      Returns the dot-separated string representation of this path.
      Specified by:
      toString in class Record
    • isEmpty

      public boolean isEmpty()
      Whether this path is empty (has no elements) or not.
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • elements

      public List<String> elements()
      Returns the value of the elements record component.
      Returns:
      the value of the elements record component