public class AnnotationAwareOrderComparator extends OrderComparator
Comparator implementation that checks
Ordered as well as the
Order annotation, with an order value provided by an
Ordered instance overriding a statically defined
annotation value (if any).| Modifier and Type | Field and Description |
|---|---|
static AnnotationAwareOrderComparator |
INSTANCE
Shared default instance of AnnotationAwareOrderComparator.
|
| Constructor and Description |
|---|
AnnotationAwareOrderComparator() |
| Modifier and Type | Method and Description |
|---|---|
protected int |
getOrder(Object obj)
Determine the order value for the given object.
|
static void |
sort(List<?> list)
Sort the given List with a default AnnotationAwareOrderComparator.
|
static void |
sort(Object[] array)
Sort the given array with a default AnnotationAwareOrderComparator.
|
static void |
sortIfNecessary(Object value)
Sort the given array or List with a default AnnotationAwareOrderComparator,
if necessary.
|
compareclone, 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 AnnotationAwareOrderComparator INSTANCE
protected int getOrder(Object obj)
OrderComparatorThe default implementation checks against the Ordered
interface. Can be overridden in subclasses.
getOrder in class OrderComparatorobj - the object to checkOrdered.LOWEST_PRECEDENCE as fallbackpublic static void sort(List<?> list)
Optimized to skip sorting for lists with size 0 or 1, in order to avoid unnecessary array extraction.
list - the List to sortCollections.sort(java.util.List, java.util.Comparator)public static void sort(Object[] array)
Optimized to skip sorting for lists with size 0 or 1, in order to avoid unnecessary array extraction.
array - the array to sortArrays.sort(Object[], java.util.Comparator)public static void sortIfNecessary(Object value)
Optimized to skip sorting for lists with size 0 or 1, in order to avoid unnecessary array extraction.
value - the array or List to sortArrays.sort(Object[], java.util.Comparator)