Package io.micronaut.core.order
Class OrderUtil
java.lang.Object
io.micronaut.core.order.OrderUtil
Apply the
Ordered
interface to lists or arrays.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Comparator<Object>
Provide a comparator for collections.static final Comparator<Object>
Provide a comparator, in reversed order, for collections. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
getOrder
(@NonNull AnnotationMetadata annotationMetadata) Get the order for the given annotation metadata.static int
getOrder
(AnnotationMetadata annotationMetadata, Object o) Get the order of the given object.static int
Get the order for the given Ordered object.static int
Get the order for the given object.static void
reverseSort
(Object[] array) Sort the given array in reverse order.static void
reverseSort
(List<?> list) Sort the given list.static void
Sort the given array.static void
Sort the given array.static void
Sort the given list.static <T> Stream<T>
Sort the given list.
-
Field Details
-
COMPARATOR
Provide a comparator for collections. -
REVERSE_COMPARATOR
Provide a comparator, in reversed order, for collections.
-
-
Constructor Details
-
OrderUtil
public OrderUtil()
-
-
Method Details
-
sort
Sort the given list.- Parameters:
list
- The list to sort
-
sort
Sort the given list.- Type Parameters:
T
- The stream generic type- Parameters:
list
- The list to sort- Returns:
- The sorted stream
-
reverseSort
Sort the given list.- Parameters:
list
- The list to sort
-
reverseSort
Sort the given array in reverse order.- Parameters:
array
- The array to sort
-
sort
Sort the given array.- Parameters:
objects
- The array to sort
-
sort
Sort the given array.- Parameters:
objects
- The array to sort
-
getOrder
Get the order for the given object.- Parameters:
o
- The object- Returns:
Ordered.getOrder()
when object is instance of Ordered otherwiseOrdered.LOWEST_PRECEDENCE
-
getOrder
Get the order of the given object. Objects implementingOrdered
have precedence over annotation metadata withOrder
.- Parameters:
annotationMetadata
- The annotation metadatao
- The object- Returns:
- The order of the object. If no order is found,
Ordered.LOWEST_PRECEDENCE
is returned.
-
getOrder
Get the order for the given annotation metadata.- Parameters:
annotationMetadata
- The metadata- Returns:
- The order
- Since:
- 3.0.0
-
getOrder
Get the order for the given Ordered object.- Parameters:
o
- The ordered object- Returns:
- the order
-