Record Class PropertyPath.Segment

java.lang.Object
java.lang.Record
org.springframework.beans.PropertyPath.Segment
Record Components:
name - the property name, which is empty only for a root-level indexed access such as "[user]"
keys - the keys of the indexes applied to the property, with any surrounding quotes removed; never null, possibly empty
Enclosing class:
PropertyPath

public static record PropertyPath.Segment(String name, List<String> keys) extends Record
A dot-separated segment of a property path. It consists of a property name and the keys of any indexes applied to it, if the target property is an indexed collection.

For example, the path "map[key].name" has two segments: Segment["map", ["key"]] and Segment["name", []].

Since:
7.1
Author:
Brian Clozel
  • Constructor Details

    • Segment

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

    • toCanonicalName

      public String toCanonicalName()
      The canonical format of this segment alone: its name, followed by each key wrapped in brackets, quoted only when necessary.
    • withoutLastKey

      public PropertyPath.Segment withoutLastKey()
      Return a new segment instance with the same name, but dropping the last key.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • keys

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