Package io.quarkus.panache.common
Class Sort
- java.lang.Object
-
- io.quarkus.panache.common.Sort
-
public class Sort extends Object
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:
Sort.Direction
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Sort.Column
static class
Sort.Direction
Represents an SQL direction in which to sort results.static class
Sort.NullPrecedence
Represents the order of null columns.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Sort
and(String name)
Adds a sort column, in ascending order.Sort
and(String name, Sort.Direction direction)
Adds a sort column, in the given order.Sort
and(String name, Sort.Direction direction, Sort.NullPrecedence nullPrecedence)
Adds a sort column, in the given order and null precedence.Sort
and(String name, Sort.NullPrecedence nullPrecedence)
Adds a sort column, in the given null precedence.Sort
ascending()
Sets the order to ascending for all current sort columns.static Sort
ascending(String... columns)
Sort by the given columns, in ascending order.static Sort
by(String column)
Sort by the given column, in ascending order.static Sort
by(String... columns)
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.Sort
descending()
Sets the order to descending for all current sort columns.static Sort
descending(String... columns)
Sort by the given columns, in descending order.Sort
direction(Sort.Direction direction)
Sets the order to all current sort columns.static Sort
empty()
Creates an Empty Sort instance.List<Sort.Column>
getColumns()
Get the sort columns
-
-
-
Method Detail
-
by
public static Sort by(String column)
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(String, Direction)
,by(String...)
-
by
public static Sort by(String column, Sort.Direction direction)
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(String)
,by(String...)
-
by
public static Sort by(String column, Sort.NullPrecedence nullPrecedence)
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(String)
,by(String...)
-
by
public 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.- 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(String)
,by(String...)
-
by
public static Sort by(String... columns)
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:
by(String, Direction)
,by(String)
,ascending(String...)
,descending(String...)
-
ascending
public static Sort ascending(String... columns)
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:
by(String, Direction)
,by(String)
,by(String...)
,descending(String...)
-
descending
public static Sort descending(String... columns)
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:
by(String, Direction)
,by(String)
,descending(String...)
-
descending
public Sort descending()
Sets the order to descending for all current sort columns.- Returns:
- this instance, modified.
- See Also:
ascending()
,direction(Direction)
-
ascending
public Sort ascending()
Sets the order to ascending for all current sort columns.- Returns:
- this instance, modified.
- See Also:
descending()
,direction(Direction)
-
direction
public Sort direction(Sort.Direction 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:
descending()
,ascending()
-
and
public Sort and(String name)
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(String, Direction)
-
and
public Sort and(String name, Sort.Direction direction)
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(String)
-
and
public Sort and(String name, Sort.NullPrecedence nullPrecedence)
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(String)
-
and
public Sort and(String name, Sort.Direction direction, Sort.NullPrecedence nullPrecedence)
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:
and(String)
-
getColumns
public List<Sort.Column> getColumns()
Get the sort columns- Returns:
- the sort columns
-
empty
public static Sort empty()
Creates an Empty Sort instance. Equivalent to#by()
.- Returns:
- a new empty Sort instance
- See Also:
by(String[])
-
-