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
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Enumeration for sort directions.static enum
Enumeration for null handling hints that can be used inSort.Order
expressions.static class
PropertyPath implements the pairing of anSort.Direction
and a property.static class
Extension of Sort to use method handles to define properties to sort by. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a newSort
with the current setup but ascending order direction.static Sort
Creates a newSort
for the given properties.static Sort
by
(List<Sort.Order> orders) Creates a newSort
for the givenSort.Order
s.static Sort
by
(Sort.Direction direction, String... properties) Creates a newSort
for the givenSort.Order
s.static Sort
by
(Sort.Order... orders) Creates a newSort
for the givenSort.Order
s.Returns a newSort
with the current setup but descending order direction.boolean
getOrderFor
(String property) Returns the order registered for the given property.int
hashCode()
boolean
isEmpty()
Returns whether the currentStreamable
is empty.boolean
isSorted()
boolean
iterator()
static <T> Sort.TypedSort<T>
Creates a newSort.TypedSort
for the given type.toString()
static Sort
unsorted()
Returns aSort
instances representing no sorting setup at all.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
DEFAULT_DIRECTION
-
-
Constructor Details
-
Sort
-
-
Method Details
-
by
Creates a newSort
for the given properties.- Parameters:
properties
- must not be null.- Returns:
-
by
Creates a newSort
for the givenSort.Order
s.- Parameters:
orders
- must not be null.- Returns:
-
by
Creates a newSort
for the givenSort.Order
s.- Parameters:
orders
- must not be null.- Returns:
-
by
Creates a newSort
for the givenSort.Order
s.- Parameters:
direction
- must not be null.properties
- must not be null.- Returns:
-
sort
Creates a newSort.TypedSort
for the given type.- Parameters:
type
- must not be null.- Returns:
- Since:
- 2.2
-
unsorted
Returns aSort
instances representing no sorting setup at all.- Returns:
-
descending
Returns a newSort
with the current setup but descending order direction.- Returns:
-
ascending
Returns a newSort
with the current setup but ascending order direction.- Returns:
-
isSorted
public boolean isSorted() -
isEmpty
public boolean isEmpty()Description copied from interface:Streamable
Returns whether the currentStreamable
is empty.- Specified by:
isEmpty
in 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:
iterator
in interfaceIterable<Sort.Order>
-
equals
-
hashCode
public int hashCode() -
toString
-