java.lang.Object
org.elasticsearch.common.util.CollectionUtils
Collections-related utility methods.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> List<E> appendToCopy(Collection<E> collection, E element) Creates a copy of the given collection with the given element appended.static <E> List<E> appendToCopyNoNullElements(Collection<E> collection, E element) Same asappendToCopy(Collection, Object)but faster by assuming that all elements in the collection and the given element are non-null.static <E> List<E> appendToCopyNoNullElements(Collection<E> collection, E... elements) Same asappendToCopyNoNullElements(Collection, Object)but for multiple elements to append.static <E> ArrayList<E> arrayAsArrayList(E... elements) static <E> List<E> concatLists(List<E> listA, Collection<E> listB) eagerPartition(List<E> list, int size) static voidensureNoSelfReferences(Object value, String messageHint) Deeply inspects a Map, Iterable, or Object array looking for references back to itself.static booleanChecks if the given array contains any elements.static <E> ArrayList<E> iterableAsArrayList(Iterable<? extends E> elements) static <E> List<E> static <E> ArrayList<E> newSingletonArrayList(E element) static <T> List<T> Return a rotated view of the given list with the given distance.static int[]toArray(Collection<Integer> ints) static <T> voiduniquify(List<T> list, Comparator<T> cmp) Eliminate duplicates from a sorted list in-place.static <E> List<E> wrapUnmodifiableOrEmptySingleton(List<E> list)
-
Constructor Details
-
CollectionUtils
public CollectionUtils()
-
-
Method Details
-
isEmpty
Checks if the given array contains any elements.- Parameters:
array- The array to check- Returns:
- false if the array contains an element, true if not or the array is null.
-
uniquify
Eliminate duplicates from a sorted list in-place.- Parameters:
list- A sorted list, which will be modified in place.cmp- A comparator the list is already sorted by.
-
rotate
Return a rotated view of the given list with the given distance. -
toArray
-
ensureNoSelfReferences
Deeply inspects a Map, Iterable, or Object array looking for references back to itself.- Parameters:
value- The object to evaluate looking for self referencesmessageHint- A string to be included in the exception message if the call fails, to provide more context to the handler of the exception- Throws:
IllegalArgumentException- if a self-reference is found
-
iterableAsArrayList
-
arrayAsArrayList
-
appendToCopy
Creates a copy of the given collection with the given element appended.- Parameters:
collection- collection to copyelement- element to append
-
appendToCopyNoNullElements
Same asappendToCopy(Collection, Object)but faster by assuming that all elements in the collection and the given element are non-null.- Parameters:
collection- collection to copyelement- element to append- Returns:
- list with appended element
-
appendToCopyNoNullElements
Same asappendToCopyNoNullElements(Collection, Object)but for multiple elements to append. -
newSingletonArrayList
-
eagerPartition
-
concatLists
-
wrapUnmodifiableOrEmptySingleton
-
limitSize
-