Class ListUtils
java.lang.Object
org.apache.jackrabbit.oak.commons.collections.ListUtils
Utility methods for
List conversions.-
Method Summary
Modifier and TypeMethodDescriptionpartitionList(List<T> list, int n) Split a list into partitions of a given size.static <T> @NotNull List<T>Returns a new list containing the elements of the specified list in reverse order.static <T> @NotNull List<T>toLinkedList(Iterable<T> iterable) Convert an iterable to aLinkedList.static <T> @NotNull List<T>Convert an iterable to a list.static <T> @NotNull List<T>Convert an iterator to a list.
-
Method Details
-
toList
@NotNull public static <T> @NotNull List<T> toList(@NotNull @NotNull Iterable<? extends T> iterable) Convert an iterable to a list. The returning list is mutable and supports all optional operations.- Type Parameters:
T- the type of the elements- Parameters:
iterable- the iterable to convert- Returns:
- the list
-
toLinkedList
Convert an iterable to aLinkedList. The returning LinkedList is mutable and supports all optional operations.- Type Parameters:
T- the type of the elements- Parameters:
iterable- the iterator to convert- Returns:
- the LinkedList
-
toList
Convert an iterator to a list. The returning list is mutable and supports all optional operations.- Type Parameters:
T- the type of the elements- Parameters:
iterator- the iterator to convert- Returns:
- the list
-
partitionList
Split a list into partitions of a given size.- Type Parameters:
T- the type of the elements- Parameters:
list- the list to partitionn- the size of partitions- Returns:
- a list of partitions. The resulting partitions aren’t a view of the main List, so any changes happening to the main List won’t affect the partitions.
-
reverse
Returns a new list containing the elements of the specified list in reverse order.- Type Parameters:
T- the type of elements in the list- Parameters:
l- the list to be reversed, must not be null- Returns:
- a new list containing the elements of the specified list in reverse order
- Throws:
NullPointerException- if the list is null
-