类 AnnotationAwareOrderComparator
- java.lang.Object
- org.springframework.core.OrderComparator
- org.springframework.core.annotation.AnnotationAwareOrderComparator
- 所有已实现的接口:
Comparator<Object>
public class AnnotationAwareOrderComparator extends OrderComparator
AnnotationAwareOrderComparator
is an extension ofOrderComparator
that supports Spring'sOrdered
interface as well as the@Order
and@Priority
annotations, with an order value provided by anOrdered
instance overriding a statically defined annotation value (if any).Consult the Javadoc for
OrderComparator
for details on the sort semantics for non-ordered objects.
嵌套类概要
从类继承的嵌套类/接口 org.springframework.core.OrderComparator
OrderComparator.OrderSourceProvider
字段概要
字段 修饰符和类型 字段 说明 static AnnotationAwareOrderComparator
INSTANCE
Shared default instance ofAnnotationAwareOrderComparator
.
构造器概要
构造器 构造器 说明 AnnotationAwareOrderComparator()
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 protected Integer
findOrder(Object obj)
Integer
getPriority(Object obj)
static void
sort(Object[] array)
Sort the given array with a default AnnotationAwareOrderComparator.static void
sort(List<?> list)
Sort the given List with a default AnnotationAwareOrderComparator.static void
sortIfNecessary(Object value)
Sort the given array or List with a default AnnotationAwareOrderComparator, if necessary.从类继承的方法 org.springframework.core.OrderComparator
compare, getOrder, withSourceProvider
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
字段详细资料
INSTANCE
public static final AnnotationAwareOrderComparator INSTANCE
Shared default instance ofAnnotationAwareOrderComparator
.
构造器详细资料
AnnotationAwareOrderComparator
public AnnotationAwareOrderComparator()
方法详细资料
findOrder
protected Integer findOrder(Object obj)
This implementation checks for@Order
or@Priority
on various kinds of elements, in addition to theOrdered
check in the superclass.- 覆盖:
findOrder
在类中OrderComparator
- 参数:
obj
- the object to check- 返回:
- the order value, or
null
if none found
getPriority
public Integer getPriority(Object obj)
This implementation retrieves an @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
在类中OrderComparator
- 参数:
obj
- the object to check- 返回:
- the priority value, or
null
if none
sort
public static void sort(List<?> list)
Sort the given List with a default AnnotationAwareOrderComparator.Optimized to skip sorting for lists with size 0 or 1, in order to avoid unnecessary array extraction.
- 参数:
list
- the List to sort- 另请参阅:
Collections.sort(java.util.List, java.util.Comparator)
sort
public static void sort(Object[] array)
Sort the given array with a default AnnotationAwareOrderComparator.Optimized to skip sorting for lists with size 0 or 1, in order to avoid unnecessary array extraction.
- 参数:
array
- the array to sort- 另请参阅:
Arrays.sort(Object[], java.util.Comparator)
sortIfNecessary
public static void sortIfNecessary(Object value)
Sort the given array or List with a default AnnotationAwareOrderComparator, if necessary. Simply skips sorting when given any other 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 sort- 另请参阅:
Arrays.sort(Object[], java.util.Comparator)