Top Description Fields Constructors Methods
org.springframework.core.annotation

public abstract Class OrderUtils

extends Object
Class Inheritance
Imports
java.lang.reflect.AnnotatedElement, java.util.Map, org.springframework.core.annotation.MergedAnnotations.SearchStrategy, org.springframework.lang.Nullable, org.springframework.util.ConcurrentReferenceHashMap

General utility for determining the order of an object based on its type declaration. Handles Spring's Order annotation as well as jakarta.annotation.Priority.
Authors
Stephane Nicoll, Juergen Hoeller
Since
4.1
See Also
Order, jakarta.annotation.Priority

Field Summary

Modifier and TypeField and Description
private static final String
private static final Object
NOT_ANNOTATED

Cache marker for a non-annotated Class.

pack-priv static final Map<AnnotatedElement, Object>
orderCache

Cache for @Order value (or NOT_ANNOTATED marker) per Class.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static Integer
public static int

Returns:

the priority value, or the specified default order if none can be found
getOrder
(Class<?>
the type to handle
type
,
int defaultOrder)

Return the order on the specified type, or the specified default value if none can be found.

public static Integer

Returns:

the priority value, or the specified default order if none can be found
getOrder
(Class<?>
the type to handle
type
,
Integer defaultOrder)

Return the order on the specified type, or the specified default value if none can be found.

public static Integer

Returns:

the order value, or null if none can be found
getOrder
(Class<?>
the type to handle
type
)

Return the order on the specified type.

public static Integer

Returns:

the order value, or null if none can be found
getOrder
(AnnotatedElement
the annotated element (e.g. type or method)
element
)

Return the order declared on the specified element.

pack-priv static Integer

Returns:

the order value, or null if none can be found
getOrderFromAnnotations
(AnnotatedElement
the source element
element
,
MergedAnnotations
the annotation to consider
annotations
)

Return the order from the specified annotations collection.

public static Integer

Returns:

the priority value if the annotation is declared, or null if none
getPriority
(Class<?>
the type to handle
type
)

Return the value of the jakarta.annotation.Priority annotation declared on the specified type, or null if none.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

JAVAX_PRIORITY_ANNOTATIONback to summary
private static final String JAVAX_PRIORITY_ANNOTATION
NOT_ANNOTATEDback to summary
private static final Object NOT_ANNOTATED

Cache marker for a non-annotated Class.

orderCacheback to summary
pack-priv static final Map<AnnotatedElement, Object> orderCache

Cache for @Order value (or NOT_ANNOTATED marker) per Class.

Constructor Detail

OrderUtilsback to summary
public OrderUtils()

Method Detail

findOrderback to summary
private static Integer findOrder(MergedAnnotations annotations)
Annotations
@Nullable
getOrderback to summary
public static int getOrder(Class<?> type, int defaultOrder)

Return the order on the specified type, or the specified default value if none can be found.

Takes care of @Order and @jakarta.annotation.Priority.

Parameters
type:Class<?>

the type to handle

Returns:int

the priority value, or the specified default order if none can be found

Since
5.0
See Also
getPriority(Class)
getOrderback to summary
public static Integer getOrder(Class<?> type, Integer defaultOrder)

Return the order on the specified type, or the specified default value if none can be found.

Takes care of @Order and @jakarta.annotation.Priority.

Parameters
type:Class<?>

the type to handle

Returns:Integer

the priority value, or the specified default order if none can be found

Annotations
@Nullable
See Also
getPriority(Class)
getOrderback to summary
public static Integer getOrder(Class<?> type)

Return the order on the specified type.

Takes care of @Order and @jakarta.annotation.Priority.

Parameters
type:Class<?>

the type to handle

Returns:Integer

the order value, or null if none can be found

Annotations
@Nullable
See Also
getPriority(Class)
getOrderback to summary
public static Integer getOrder(AnnotatedElement element)

Return the order declared on the specified element.

Takes care of @Order and @jakarta.annotation.Priority.

Parameters
element:AnnotatedElement

the annotated element (e.g. type or method)

Returns:Integer

the order value, or null if none can be found

Annotations
@Nullable
Since
5.3
getOrderFromAnnotationsback to summary
pack-priv static Integer getOrderFromAnnotations(AnnotatedElement element, MergedAnnotations annotations)

Return the order from the specified annotations collection.

Takes care of @Order and @jakarta.annotation.Priority.

Parameters
element:AnnotatedElement

the source element

annotations:MergedAnnotations

the annotation to consider

Returns:Integer

the order value, or null if none can be found

Annotations
@Nullable
getPriorityback to summary
public static Integer getPriority(Class<?> type)

Return the value of the jakarta.annotation.Priority annotation declared on the specified type, or null if none.

Parameters
type:Class<?>

the type to handle

Returns:Integer

the priority value if the annotation is declared, or null if none

Annotations
@Nullable