Package io.quarkus.panache.common
Class Sort
java.lang.Object
io.quarkus.panache.common.Sort
Utility class to build and represent SQL sorting specifications. A Sort
instance represents
a list of columns to sort on, each with a direction to use for sorting.
Usage:
Sort sort = Sort.by("name").and("age", Direction.Descending);
Sort sort2 = Sort.ascending("name", "age");
Sort sort3 = Sort.descending("name", "age");
- Author:
- Stéphane Épardaud
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static enum
Represents an SQL direction in which to sort results.static enum
Represents the order of null columns. -
Method Summary
Modifier and TypeMethodDescriptionAdds a sort column, in ascending order.and
(String name, Sort.Direction direction) Adds a sort column, in the given order.and
(String name, Sort.Direction direction, Sort.NullPrecedence nullPrecedence) Adds a sort column, in the given order and null precedence.and
(String name, Sort.NullPrecedence nullPrecedence) Adds a sort column, in the given null precedence.Sets the order to ascending for all current sort columns.static Sort
Sort by the given columns, in ascending order.static Sort
Sort by the given column, in ascending order.static Sort
Sort by the given columns, in ascending order.static Sort
by
(String column, Sort.Direction direction) Sort by the given column, in the given order.static Sort
by
(String column, Sort.Direction direction, Sort.NullPrecedence nullPrecedence) Sort by the given column, in the given order and in the given null precedence.static Sort
by
(String column, Sort.NullPrecedence nullPrecedence) Sort by the given column, in the given order and in the given null precedence.Sets the order to descending for all current sort columns.static Sort
descending
(String... columns) Sort by the given columns, in descending order.direction
(Sort.Direction direction) Sets the order to all current sort columns.static Sort
empty()
Creates an Empty Sort instance.Get the sort columns
-
Method Details
-
by
Sort by the given column, in ascending order.- Parameters:
column
- the column to sort on, in ascending order.- Returns:
- a new Sort instance which sorts on the given column in ascending order.
- See Also:
-
by
Sort by the given column, in the given order.- Parameters:
column
- the column to sort on, in the given order.direction
- the direction to sort on.- Returns:
- a new Sort instance which sorts on the given column in the given order.
- See Also:
-
by
Sort by the given column, in the given order and in the given null precedence.- Parameters:
column
- the column to sort on, in the given order.nullPrecedence
- the null precedence to use.- Returns:
- a new Sort instance which sorts on the given column in the given order and null precedence.
- See Also:
-
by
Sort by the given column, in the given order and in the given null precedence.- Parameters:
column
- the column to sort on, in the given order.direction
- the direction to sort on.nullPrecedence
- the null precedence to use.- Returns:
- a new Sort instance which sorts on the given column in the given order and null precedence.
- See Also:
-
by
Sort by the given columns, in ascending order. Equivalent toascending(String...)
.- Parameters:
columns
- the columns to sort on, in ascending order.- Returns:
- a new Sort instance which sorts on the given columns in ascending order.
- See Also:
-
ascending
Sort by the given columns, in ascending order. Equivalent toby(String...)
.- Parameters:
columns
- the columns to sort on, in ascending order.- Returns:
- a new Sort instance which sorts on the given columns in ascending order.
- See Also:
-
descending
Sort by the given columns, in descending order.- Parameters:
columns
- the columns to sort on, in descending order.- Returns:
- a new Sort instance which sorts on the given columns in descending order.
- See Also:
-
descending
Sets the order to descending for all current sort columns.- Returns:
- this instance, modified.
- See Also:
-
ascending
Sets the order to ascending for all current sort columns.- Returns:
- this instance, modified.
- See Also:
-
direction
Sets the order to all current sort columns.- Parameters:
direction
- the direction to use for all current sort columns.- Returns:
- this instance, modified.
- See Also:
-
and
Adds a sort column, in ascending order.- Parameters:
name
- the new column to sort on, in ascending order.- Returns:
- this instance, modified.
- See Also:
-
and
Adds a sort column, in the given order.- Parameters:
name
- the new column to sort on, in the given order.direction
- the direction to sort on.- Returns:
- this instance, modified.
- See Also:
-
and
Adds a sort column, in the given null precedence.- Parameters:
name
- the new column to sort on, in the given null precedence.nullPrecedence
- the null precedence to use.- Returns:
- this instance, modified.
- See Also:
-
and
Adds a sort column, in the given order and null precedence.- Parameters:
name
- the new column to sort on, in the given order and null precedence.direction
- the direction to sort on.nullPrecedence
- the null precedence to use.- Returns:
- this instance, modified.
- See Also:
-
getColumns
Get the sort columns- Returns:
- the sort columns
-
empty
Creates an Empty Sort instance. Equivalent to#by()
.- Returns:
- a new empty Sort instance
- See Also:
-