Modifier and Type | Field and Description |
---|---|
static Comparator<Object> |
COMPARATOR
Provide a comparator for collections.
|
static Comparator<Object> |
REVERSE_COMPARATOR
Provide a comparator, in reversed order, for collections.
|
Constructor and Description |
---|
OrderUtil() |
Modifier and Type | Method and Description |
---|---|
static int |
getOrder(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 |
getOrder(Object o)
Get the order for the given object.
|
static int |
getOrder(Ordered o)
Get the order for the given Ordered object.
|
static void |
reverseSort(List<?> list)
Sort the given list.
|
static void |
reverseSort(Object[] array)
Sort the given array in reverse order.
|
static void |
sort(List<?> list)
Sort the given list.
|
static void |
sort(Object[] objects)
Sort the given array.
|
static void |
sort(Ordered... objects)
Sort the given array.
|
static <T> Stream<T> |
sort(Stream<T> list)
Sort the given list.
|
public static final Comparator<Object> COMPARATOR
public static final Comparator<Object> REVERSE_COMPARATOR
public static void sort(List<?> list)
list
- The list to sortpublic static <T> Stream<T> sort(Stream<T> list)
T
- The stream generic typelist
- The list to sortpublic static void reverseSort(List<?> list)
list
- The list to sortpublic static void reverseSort(Object[] array)
array
- The array to sortpublic static void sort(Ordered... objects)
objects
- The array to sortpublic static void sort(Object[] objects)
objects
- The array to sortpublic static int getOrder(Object o)
o
- The objectOrdered.getOrder()
when object is instance of Ordered otherwise Ordered.LOWEST_PRECEDENCE
public static int getOrder(AnnotationMetadata annotationMetadata, Object o)
Ordered
have precedence
over annotation metadata with Order
.annotationMetadata
- The annotation metadatao
- The objectOrdered.LOWEST_PRECEDENCE
is returned.public static int getOrder(@NonNull AnnotationMetadata annotationMetadata)
annotationMetadata
- The metadatapublic static int getOrder(Ordered o)
o
- The ordered object