T
- The type to be sortedList<T> predefinedList = Arrays.<T>asList(predefinedOrder);
FixedOrderComparator<T> fixedComparator = new FixedOrderComparator<>(predefinedList);
fixedComparator.setUnknownObjectBehavior(FixedOrderComparator.UnknownObjectBehavior.AFTER);
Comparator<T> c = new ComparatorChain<>(Arrays.<Comparator<T>>asList(
fixedComparator,
new NullComparator<>(false),
new ComparableComparator<>()));
@Deprecated public class LiteralComparator<T extends Comparable<T>> extends Object implements Comparator<T>, Serializable
Comparator
takes an array of literals that define an
order.
Anything not included in the array is placed after anything in the array and
is then sorted according to its natural order.Constructor and Description |
---|
LiteralComparator(T[] predefinedOrder)
Deprecated.
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(T o1,
T o2)
Deprecated.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public LiteralComparator(T[] predefinedOrder)
predefinedOrder
- Objects that define the order of comparisonpublic int compare(T o1, T o2)
compare
in interface Comparator<T extends Comparable<T>>
Copyright © 2005–2023. All rights reserved.