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");
Sort.Direction
Modifier and Type | Class and Description |
---|---|
class |
Sort.Column |
static class |
Sort.Direction
Represents an SQL direction in which to sort results.
|
Modifier and Type | Method and 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 |
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... 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 column,
Sort.Direction direction)
Sort by the given column, in the given order.
|
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.
|
List<Sort.Column> |
getColumns()
Get the sort columns
|
String |
toOrderBy()
Deprecated.
panache-common should be agnostic from the database implementation
|
public static Sort by(String column)
column
- the column to sort on, in ascending order.by(String, Direction)
,
by(String...)
public static Sort by(String column, Sort.Direction direction)
column
- the column to sort on, in the given order.direction
- the direction to sort onby(String)
,
by(String...)
public static Sort by(String... columns)
ascending(String...)
.columns
- the columns to sort on, in ascending order.by(String, Direction)
,
by(String)
,
ascending(String...)
,
descending(String...)
public static Sort ascending(String... columns)
by(String...)
.columns
- the columns to sort on, in ascending order.by(String, Direction)
,
by(String)
,
by(String...)
,
descending(String...)
public static Sort descending(String... columns)
columns
- the columns to sort on, in descending order.by(String, Direction)
,
by(String)
,
descending(String...)
public Sort descending()
ascending()
,
direction(Direction)
public Sort ascending()
descending()
,
direction(Direction)
public Sort direction(Sort.Direction direction)
direction
- the direction to use for all current sort columns.descending()
,
ascending()
public Sort and(String name)
name
- the new column to sort on, in ascending order.and(String, Direction)
public Sort and(String name, Sort.Direction direction)
name
- the new column to sort on, in the given order.and(String)
public List<Sort.Column> getColumns()
@Deprecated public String toOrderBy()
Copyright © 2019 JBoss by Red Hat. All rights reserved.