public class AnnotationAwareOrderComparator extends OrderComparator
OrderComparator.OrderSourceProvider
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 java.lang.Integer |
findOrder(java.lang.Object obj)
|
java.lang.Integer |
getPriority(java.lang.Object obj)
This implementation retrieves an @
javax.annotation.Priority
value, allowing for additional semantics over the regular @Order
annotation: typically, selecting one object over another in case of
multiple matches but only one object to be returned. |
static void |
sort(java.util.List<?> list)
Sort the given List with a default AnnotationAwareOrderComparator.
|
static void |
sort(java.lang.Object[] array)
Sort the given array with a default AnnotationAwareOrderComparator.
|
static void |
sortIfNecessary(java.lang.Object value)
Sort the given array or List with a default AnnotationAwareOrderComparator,
if necessary.
|
compare, getOrder, withSourceProvider
public static final AnnotationAwareOrderComparator INSTANCE
protected java.lang.Integer findOrder(java.lang.Object obj)
Order
annotation
on various kinds of elements, in addition to the
Ordered
check in the superclass.findOrder
in class OrderComparator
obj
- the object to checknull
if none foundpublic java.lang.Integer getPriority(java.lang.Object obj)
javax.annotation.Priority
value, allowing for additional semantics over the regular @Order
annotation: typically, selecting one object over another in case of
multiple matches but only one object to be returned.getPriority
in class OrderComparator
obj
- the object to checknull
if nonepublic static void sort(java.util.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(java.lang.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(java.lang.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)