Package org.springframework.data.domain
Class Sort
java.lang.Object
org.springframework.data.domain.Sort
- All Implemented Interfaces:
Serializable,Iterable<Sort.Order>,Supplier<Stream<Sort.Order>>,Streamable<Sort.Order>
- Direct Known Subclasses:
QSort,RevisionSort,Sort.TypedSort
Sort option for queries. You have to provide at least a list of properties to sort for that must not include
null or empty strings. The direction defaults to
DEFAULT_DIRECTION.- Author:
- Oliver Gierke, Thomas Darimont, Mark Paluch, Johannes Englmeier
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration for sort directions.static enumEnumeration for null handling hints that can be used inSort.Orderexpressions.static classPropertyPath implements the pairing of anSort.Directionand a property.static classExtension of Sort to use method handles to define properties to sort by. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a newSortwith the current setup but ascending order direction.static SortCreates a newSortfor the given properties.static Sortby(List<Sort.Order> orders) Creates a newSortfor the givenSort.Orders.static Sortby(Sort.Direction direction, String... properties) Creates a newSortfor the givenSort.Directionand properties.static Sortby(Sort.Order... orders) Creates a newSortfor the givenSort.Orders.Returns a newSortwith the current setup but descending order direction.booleangetOrderFor(String property) Returns the order registered for the given property.inthashCode()booleanisEmpty()Returns whether the currentStreamableis empty.booleanisSorted()booleaniterator()static <T> Sort.TypedSort<T>Creates a newSort.TypedSortfor the given type.toString()static Sortunsorted()Returns aSortinstances representing no sorting setup at all.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
DEFAULT_DIRECTION
-
-
Constructor Details
-
Sort
-
-
Method Details
-
by
Creates a newSortfor the given properties.- Parameters:
properties- must not be null.- Returns:
-
by
Creates a newSortfor the givenSort.Orders.- Parameters:
orders- must not be null.- Returns:
-
by
Creates a newSortfor the givenSort.Orders.- Parameters:
orders- must not be null.- Returns:
-
by
Creates a newSortfor the givenSort.Directionand properties.- Parameters:
direction- must not be null.properties- must not be null.- Returns:
-
sort
Creates a newSort.TypedSortfor the given type.- Parameters:
type- must not be null.- Returns:
- Since:
- 2.2
-
unsorted
Returns aSortinstances representing no sorting setup at all.- Returns:
-
descending
Returns a newSortwith the current setup but descending order direction.- Returns:
-
ascending
Returns a newSortwith the current setup but ascending order direction.- Returns:
-
isSorted
public boolean isSorted() -
isEmpty
public boolean isEmpty()Description copied from interface:StreamableReturns whether the currentStreamableis empty.- Specified by:
isEmptyin interfaceStreamable<Sort.Order>- Returns:
-
isUnsorted
public boolean isUnsorted() -
and
- Parameters:
sort- must not be null.- Returns:
-
getOrderFor
Returns the order registered for the given property.- Parameters:
property-- Returns:
-
iterator
- Specified by:
iteratorin interfaceIterable<Sort.Order>
-
equals
-
hashCode
public int hashCode() -
toString
-