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<Ordered>
The comparator of elements implementingOrdered
.static final Comparator<Object>
Provide a comparator, in reversed order, for collections.static final Comparator<Ordered>
The reverse comparator of elements implementingOrdered
. -
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
Deprecated, for removal: This API element is subject to removal in a future version.Inline methodstatic 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 <T extends Ordered>
voidreverseSortOrdered
(List<T> 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.static <T extends Ordered>
voidsortOrdered
(List<T> list) Sort the given list.sortOrdered
(Stream<T> list) Sort the given stream.sortOrderedCollection
(Collection<T> list) Sort the given list.
-
Field Details
-
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
-
sortOrdered
Sort the given stream.- Type Parameters:
T
- The stream generic type- Parameters:
list
- The list to sort- Returns:
- The sorted stream
- Since:
- 4.4.0
-
sortOrderedCollection
Sort the given list.- Type Parameters:
T
- The type- Parameters:
list
- The list to sort- Returns:
- The sorted collection
- Since:
- 4.4.0
-
sortOrdered
Sort the given list.- Type Parameters:
T
- The type- Parameters:
list
- The list to sort- Since:
- 4.4.0
-
reverseSortOrdered
Sort the given list.- Type Parameters:
T
- The type- Parameters:
list
- The list to sort- Since:
- 4.4.0
-
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
Deprecated, for removal: This API element is subject to removal in a future version.Inline methodGet the order for the given Ordered object.- Parameters:
o
- The ordered object- Returns:
- the order
-