public class OrderByComparator<T> extends Object implements Comparator<T>
An OrderByComparator is a Comparator that is
capable of comparing two objects based on a dynamic list of properties of
the objects of type T. It can sort any of its properties
ascending or descending, and for any of its properties, it can place nulls
first or last. Like SQL, this will default to ascending. Nulls default to
last if ascending, and first if descending.
| Modifier and Type | Field and Description |
|---|---|
static String |
ASC
Sort ascending (default).
|
static String |
DESC
Sort descending.
|
static int |
ORDER_ASC
Constant to order ascending.
|
static int |
ORDER_DESC
Constant to order descending.
|
| Constructor and Description |
|---|
OrderByComparator(List<String> expressions,
UtilWrapper util)
Constructs an
OrderByComparator based on a List
of expressions, of the format "property [ASC|DESC]". |
| Modifier and Type | Method and Description |
|---|---|
int |
compare(T o1,
T o2) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcomparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongpublic static final String ASC
public static final String DESC
public static final int ORDER_ASC
public static final int ORDER_DESC
public OrderByComparator(List<String> expressions, UtilWrapper util)
OrderByComparator based on a List
of expressions, of the format "property [ASC|DESC]".expressions - A List of expressions.ParseException - If there is a problem parsing the expressions.public int compare(T o1, T o2) throws UnsupportedOperationException
compare in interface Comparator<T>UnsupportedOperationExceptionCopyright © 2020. All rights reserved.