java.lang.Object
org.springframework.data.repository.query.parser.PartTree
All Implemented Interfaces:
Iterable<PartTree.OrPart>, Supplier<Stream<PartTree.OrPart>>, Streamable<PartTree.OrPart>

public class PartTree extends Object implements Streamable<PartTree.OrPart>
Class to parse a String into a tree or PartTree.OrParts consisting of simple Part instances in turn. Takes a domain class as well to validate that each of the Parts are referring to a property of the domain class. The PartTree can then be used to build queries based on its API instead of parsing the method name for each query execution.
Author:
Oliver Gierke, Thomas Darimont, Christoph Strobl, Mark Paluch, Shaun Chyxion, Johannes Englmeier
  • Constructor Details

    • PartTree

      public PartTree(String source, Class<?> domainClass)
      Creates a new PartTree by parsing the given String.
      Parameters:
      source - the String to parse
      domainClass - the domain class to check individual parts against to ensure they refer to a property of the class
  • Method Details

    • iterator

      public Iterator<PartTree.OrPart> iterator()
      Specified by:
      iterator in interface Iterable<PartTree.OrPart>
    • getSort

      public Sort getSort()
      Returns the Sort specification parsed from the source.
      Returns:
      never null.
    • isDistinct

      public boolean isDistinct()
      Returns whether we indicate distinct lookup of entities.
      Returns:
      true if distinct
    • isCountProjection

      public boolean isCountProjection()
      Returns whether a count projection shall be applied.
      Returns:
    • isExistsProjection

      public boolean isExistsProjection()
      Returns whether an exists projection shall be applied.
      Returns:
      Since:
      1.13
    • isDelete

      public boolean isDelete()
      return true if the created PartTree is meant to be used for delete operation.
      Returns:
      Since:
      1.8
    • isLimiting

      public boolean isLimiting()
      Return true if the create PartTree is meant to be used for a query with limited maximal results.
      Returns:
      Since:
      1.9
    • getMaxResults

      @Nullable public Integer getMaxResults()
      Return the number of maximal results to return or null if not restricted.
      Returns:
      null if not restricted.
      Since:
      1.9
    • getParts

      public Streamable<Part> getParts()
      Returns an Iterable of all parts contained in the PartTree.
      Returns:
      the iterable Parts
    • getParts

      public Streamable<Part> getParts(Part.Type type)
      Returns all Parts of the PartTree of the given Part.Type.
      Parameters:
      type -
      Returns:
    • hasPredicate

      public boolean hasPredicate()
      Returns whether the PartTree contains predicate Parts.
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object