Interface PropertyPath

All Superinterfaces:
Iterable<PropertyPath>, Streamable<PropertyPath>, Supplier<Stream<PropertyPath>>

public interface PropertyPath extends Streamable<PropertyPath>
Abstraction of a PropertyPath within a domain class.
Author:
Oliver Gierke, Christoph Strobl, Mark Paluch, Mariusz MÄ…czkowski, Johannes Englmeier
  • Method Details

    • getOwningType

      TypeInformation<?> getOwningType()
      Returns the owning type of the PropertyPath.
      Returns:
      the owningType will never be null.
    • getSegment

      String getSegment()
      Returns the first part of the PropertyPath. For example:
      PropertyPath.from("a.b.c", Some.class).getSegment();
      
      results in a.
      Returns:
      the name will never be null.
    • getLeafProperty

      default PropertyPath getLeafProperty()
      Returns the leaf property of the PropertyPath.
      Returns:
      will never be null.
    • getLeafType

      default Class<?> getLeafType()
      Returns the type of the leaf property of the current PropertyPath.
      Returns:
      will never be null.
    • getType

      default Class<?> getType()
      Returns the actual type of the property. Will return the plain resolved type for simple properties, the component type for any Iterable or the value type of a Map.
      Returns:
      the actual type of the property.
    • getTypeInformation

      TypeInformation<?> getTypeInformation()
      Returns the type information of the property.
      Returns:
      the actual type of the property.
    • next

      @Nullable PropertyPath next()
      Returns the PropertyPath path that results from removing the first element of the current one. For example:
      PropertyPath.from("a.b.c", Some.class).next().toDotPath();
      
      results in the output: b.c
      Returns:
      the next nested PropertyPath or null if no nested PropertyPath available.
      See Also:
    • hasNext

      default boolean hasNext()
      Returns whether there is a nested PropertyPath. If this returns true you can expect next() to return a non- null value.
      Returns:
    • toDotPath

      default String toDotPath()
      Returns the PropertyPath in dot notation.
      Returns:
      the PropertyPath in dot notation.
    • isCollection

      default boolean isCollection()
      Returns whether the PropertyPath is actually a collection.
      Returns:
      true whether the PropertyPath is actually a collection.
    • nested

      default PropertyPath nested(String path)
      Returns the PropertyPath for the path nested under the current property.
      Parameters:
      path - must not be null or empty.
      Returns:
      will never be null.
    • iterator

      Iterator<PropertyPath> iterator()
      Returns an Iterator of PropertyPath that iterates over all the partial property paths with the same leaf type but decreasing length. For example:
      PropertyPath propertyPath = PropertyPath.from("a.b.c", Some.class);
      propertyPath.forEach(p -> p.toDotPath());
      
      results in the dot paths:
      a.b.c
      b.c
      c
      
      Specified by:
      iterator in interface Iterable<PropertyPath>
    • from

      static PropertyPath from(String source, Class<?> type)
      Extracts the PropertyPath chain from the given source String and TypeInformation.
      Uses (?:[%s]?([%s]*?[^%s]+)) by default and (?:[%s]?([%s]*?[^%s]+)) for quoted literals.

      Separate parts of the path may be separated by "." or by "_" or by camel case. When the match to properties is ambiguous longer property names are preferred. So for userAddressCity the interpretation userAddress.city is preferred over user.address.city.

      Parameters:
      source - a String denoting the property path, must not be null.
      type - the owning type of the property path, must not be null.
      Returns:
      a new PropertyPath guaranteed to be not null.
    • from

      static PropertyPath from(String source, TypeInformation<?> type)
      Extracts the PropertyPath chain from the given source String and TypeInformation.
      Uses (?:[%s]?([%s]*?[^%s]+)) by default and (?:[%s]?([%s]*?[^%s]+)) for quoted literals.

      Separate parts of the path may be separated by "." or by "_" or by camel case. When the match to properties is ambiguous longer property names are preferred. So for userAddressCity the interpretation userAddress.city is preferred over user.address.city.

      Parameters:
      source - a String denoting the property path, must not be null.
      type - the owning type of the property path, must not be null.
      Returns:
      a new PropertyPath guaranteed to be not null.