|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.core.OrderComparator
public class OrderComparator
Comparator implementation for Ordered objects,
sorting by order value ascending (resp. by priority descending).
Non-Ordered objects are treated as greatest order
values, thus ending up at the end of the list, in arbitrary order
(just like same order values of Ordered objects).
Ordered,
Collections.sort(java.util.List, java.util.Comparator),
Arrays.sort(Object[], java.util.Comparator)| Field Summary | |
|---|---|
static OrderComparator |
INSTANCE
Shared default instance of OrderComparator. |
| Constructor Summary | |
|---|---|
OrderComparator()
|
|
| Method Summary | |
|---|---|
int |
compare(Object o1,
Object o2)
|
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 OrderComparator. |
static void |
sort(Object[] array)
Sort the given array with a default OrderComparator. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
|---|
equals |
| Field Detail |
|---|
public static final OrderComparator INSTANCE
| Constructor Detail |
|---|
public OrderComparator()
| Method Detail |
|---|
public int compare(Object o1,
Object o2)
compare in interface Comparator<Object>protected int getOrder(Object obj)
The default implementation checks against the Ordered
interface. Can be overridden in subclasses.
obj - the object to check
Ordered.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)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||