Package io.micronaut.data.model
Interface Sort
-
- All Known Subinterfaces:
Pageable
public interface Sort
An interface for objects that can be sorted. Sorted instances are immutable and all mutating operations on this interface return a new instance.- Since:
- 1.0
- Author:
- graemerocher
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Sort.Order
The ordering of results.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<Sort.Order>
getOrderBy()
boolean
isSorted()
static Sort
of(Sort.Order... orders)
Creates a sort from an array orders.static Sort
of(java.util.List<Sort.Order> orderList)
Create a sort from the given list of orders.Sort
order(Sort.Order order)
Adds an order object.Sort
order(java.lang.String propertyName)
Orders by the specified property name (defaults to ascending).Sort
order(java.lang.String propertyName, Sort.Order.Direction direction)
Orders by the specified property name and direction.static Sort
unsorted()
-
-
-
Field Detail
-
UNSORTED
static final Sort UNSORTED
Constant for unsorted.
-
-
Method Detail
-
isSorted
boolean isSorted()
- Returns:
- Is sorting applied
-
order
@NonNull Sort order(@NonNull java.lang.String propertyName)
Orders by the specified property name (defaults to ascending).- Parameters:
propertyName
- The property name to order by- Returns:
- A new sort with the order applied
-
order
@NonNull Sort order(@NonNull Sort.Order order)
Adds an order object.- Parameters:
order
- The order object- Returns:
- A new sort with the order applied
-
order
@NonNull Sort order(@NonNull java.lang.String propertyName, @NonNull Sort.Order.Direction direction)
Orders by the specified property name and direction.- Parameters:
propertyName
- The property name to order bydirection
- Either "asc" for ascending or "desc" for descending- Returns:
- A new sort with the order applied
-
getOrderBy
@NonNull java.util.List<Sort.Order> getOrderBy()
- Returns:
- The order definitions for this sort.
-
unsorted
static Sort unsorted()
- Returns:
- Default unsorted sort instance.
-
of
@NonNull static Sort of(@Nullable java.util.List<Sort.Order> orderList)
Create a sort from the given list of orders.- Parameters:
orderList
- The order list- Returns:
- The sort
-
of
@NonNull static Sort of(Sort.Order... orders)
Creates a sort from an array orders.- Parameters:
orders
- The orders- Returns:
- The orders
-
-