Record Class PropertyPath

java.lang.Object
java.lang.Record
org.seasar.doma.internal.jdbc.entity.PropertyPath
Record Components:
segments - the list of path segments that make up this property path, must not be empty

public record PropertyPath(List<? extends PropertyPathSegment> segments) extends Record
Represents a path to a property within an object graph, composed of one or more segments.

A property path is used to navigate through object hierarchies, particularly when dealing with embeddable objects that may be nested within entities. Each segment of the path represents a step in the navigation from one object to another.

For example, a property path like "address.street" would consist of two segments: one for "address" and another for "street", allowing navigation from an entity to its embedded address object and then to the street field within that address.

This record is immutable and provides factory methods for creating and combining paths.

This class is used internally by the Doma framework for property mapping and should not be used directly by application code.

See Also:
  • Constructor Details

    • PropertyPath

      public PropertyPath(List<? extends PropertyPathSegment> segments)
      Creates an instance of a PropertyPath record class.
      Parameters:
      segments - the value for the segments record component
  • Method Details

    • name

      public String name()
      Returns the full name of this property path as a dot-separated string.

      For example, if this path has segments "address" and "street", this method would return "address.street".

      Returns:
      the full property path name with segments joined by dots
    • combine

      public static PropertyPath combine(PropertyPath path, PropertyPathSegment segment)
      Creates a new property path by combining an existing path with an additional segment.

      This method allows for building longer property paths by appending segments to existing paths. The original path is not modified; a new immutable path is returned.

      Parameters:
      path - the existing property path to extend
      segment - the segment to append to the path
      Returns:
      a new property path containing all segments from the original path plus the new segment
      Throws:
      NullPointerException - if either path or segment is null
    • of

      public static PropertyPath of(String path)
      Creates a property path from a dot-separated string representation.

      This factory method parses a string like "address.street" into a property path with appropriate segments. Each segment is created as a default property path segment.

      Parameters:
      path - the dot-separated string representation of the property path
      Returns:
      a new property path with segments parsed from the string
      Throws:
      NullPointerException - if path is null
    • toString

      public String toString()
      Returns the string representation of this property path.

      This is equivalent to calling name().

      Specified by:
      toString in class Record
      Returns:
      the full property path name with segments joined by dots
    • 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.
    • segments

      public List<? extends PropertyPathSegment> segments()
      Returns the value of the segments record component.
      Returns:
      the value of the segments record component