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
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Comparator<Object>Provide a comparator for collections.static final Comparator<Object>Provide a comparator, in reversed order, for collections. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intgetOrder(@NonNull AnnotationMetadata annotationMetadata) Get the order for the given annotation metadata.static intgetOrder(AnnotationMetadata annotationMetadata, Object o) Get the order of the given object.static intGet the order for the given Ordered object.static intGet the order for the given object.static voidreverseSort(Object[] array) Sort the given array in reverse order.static voidreverseSort(List<?> list) Sort the given list.static voidSort the given array.static voidSort the given array.static voidSort 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 implementingOrderedhave 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_PRECEDENCEis 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
-