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, Jan Kurella
- 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.protected List<Sort.Order> boolean@Nullable Sort.OrdergetOrderFor(String property) Returns the order registered for the given property.inthashCode()booleanisEmpty()Returns whether the currentStreamableis empty.booleanisSorted()booleaniterator()reverse()Returns a newSortwith reversed sortSort.Orders turning effectively asccending into descending sort order and vice versa.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 interface Iterable
forEach, spliterator
-
Field Details
-
DEFAULT_DIRECTION
-
-
Constructor Details
-
Sort
-
-
Method Details
-
by
-
by
Creates a newSortfor the givenSort.Orders.- Parameters:
orders- must not be null.- Returns:
Sortfor the givenSort.Orders.
-
by
Creates a newSortfor the givenSort.Orders.- Parameters:
orders- must not be null.- Returns:
Sortfor the givenSort.Orders.
-
by
Creates a newSortfor the givenSort.Directionand properties.- Parameters:
direction- must not be null.properties- must not be null.- Returns:
Sortfor the givenSort.Directionand properties.
-
sort
Creates a newSort.TypedSortfor the given type.- Parameters:
type- must not be null.- Returns:
Sort.TypedSortfor the given type.- Since:
- 2.2
-
unsorted
-
descending
-
ascending
-
isSorted
public boolean isSorted()- Returns:
- true if this Sort instance is sorted, false otherwise.
-
isEmpty
public boolean isEmpty()Description copied from interface:StreamableReturns whether the currentStreamableis empty.- Specified by:
isEmptyin interfaceStreamable<Sort.Order>- Returns:
-
isUnsorted
public boolean isUnsorted()- Returns:
- true if this Sort instance is unsorted, false otherwise.
-
and
- Parameters:
sort- must not be null.- Returns:
- a new
Sortconsisting of theSort.Orders of the currentSortcombined with the given ones.
-
reverse
Returns a newSortwith reversed sortSort.Orders turning effectively asccending into descending sort order and vice versa.- Returns:
- a new
Sortobject with reversed sort orders applied. - Since:
- 3.1
-
doReverse
-
getOrderFor
Returns the order registered for the given property.- Parameters:
property- name of the property that should be sorted.- Returns:
- the sort
Sort.Orderor null if the property is not sorted by.
-
iterator
- Specified by:
iteratorin interfaceIterable<Sort.Order>
-
equals
-
hashCode
-
toString
-