org.springframework.data.repository.query.parser

## Class PartTree

- 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.OrPart`s consisting of simple `Part` instances in turn. Takes a domain class as well to validate that each of the `Part`s 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

### Nested Class Summary

Nested Classes
`static class` `PartTree.OrPart` A part of the parsed source that results from splitting up the resource around Or keywords.

### Constructor Summary

Constructors
Constructor and Description
`PartTree(String source, Class<?> domainClass)` Creates a new `PartTree` by parsing the given `String`.

### Method Summary

All Methods Instance Methods Concrete Methods
`Integer` `getMaxResults()` Return the number of maximal results to return or null if not restricted.
`Streamable<Part>` `getParts()` Returns an `Iterable` of all parts contained in the `PartTree`.
`Streamable<Part>` `getParts(Part.Type type)` Returns all `Part`s of the `PartTree` of the given `Part.Type`.
`Sort` `getSort()` Returns the `Sort` specification parsed from the source.
`boolean` `hasPredicate()` Returns whether the `PartTree` contains predicate `Part`s.
`boolean` `isCountProjection()` Returns whether a count projection shall be applied.
`boolean` `isDelete()` return true if the created `PartTree` is meant to be used for delete operation.
`boolean` `isDistinct()` Returns whether we indicate distinct lookup of entities.
`boolean` `isExistsProjection()` Returns whether an exists projection shall be applied.
`boolean` `isLimiting()` Return true if the create `PartTree` is meant to be used for a query with limited maximal results.
`Iterator<PartTree.OrPart>` `iterator()`
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.springframework.data.util.Streamable

`and, and, and, and, empty, filter, flatMap, get, isEmpty, map, of, of, of, stream, toList, toSet, toStreamable, toStreamable`

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

### Constructor Detail

#### 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 Detail

#### 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 `Part`s

#### getParts

    public Streamable<Part> getParts(Part.Type type)

Returns all `Part`s of the `PartTree` of the given `Part.Type`.

Parameters:
  `type` -
Returns:

#### hasPredicate

    public boolean hasPredicate()

Returns whether the `PartTree` contains predicate `Part`s.

Returns:

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`