- Record Components:
segments- the list of path segments that make up this property path, must not be empty
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 Summary
ConstructorsConstructorDescriptionPropertyPath(List<? extends PropertyPathSegment> segments) Creates an instance of aPropertyPathrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic PropertyPathcombine(PropertyPath path, PropertyPathSegment segment) Creates a new property path by combining an existing path with an additional segment.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.name()Returns the full name of this property path as a dot-separated string.static PropertyPathCreates a property path from a dot-separated string representation.List<? extends PropertyPathSegment>segments()Returns the value of thesegmentsrecord component.toString()Returns the string representation of this property path.
-
Constructor Details
-
PropertyPath
Creates an instance of aPropertyPathrecord class.- Parameters:
segments- the value for thesegmentsrecord component
-
-
Method Details
-
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
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 extendsegment- 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
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
Returns the string representation of this property path.This is equivalent to calling
name(). -
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. -
equals
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 withObjects::equals(Object,Object). -
segments
Returns the value of thesegmentsrecord component.- Returns:
- the value of the
segmentsrecord component
-