Package org.elasticsearch.common.util
Class CollectionUtils
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> ArrayList<E>arrayAsArrayList(E... elements) static <E> ArrayList<E>asArrayList(E first, E... other) static <E> ArrayList<E>asArrayList(E first, E second, E... other) static <E> List<E>concatLists(List<E> listA, List<E> listB) static <R,T> Map<R, T> Returns an unmodifiable copy of the given map.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> ArrayList<E>newSingletonArrayList(E element) static <T> List<T>Return a rotated view of the given list with the given distance.static voidsort(com.carrotsearch.hppc.ObjectArrayList<byte[]> array) static voidsort(org.apache.lucene.util.BytesRefArray bytes, int[] indices) static voidsortAndDedup(com.carrotsearch.hppc.ObjectArrayList<byte[]> array) static intsortAndDedup(org.apache.lucene.util.BytesRefArray bytes, int[] indices) static int[]toArray(Collection<Integer> ints) 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.
-
rotate
Return a rotated view of the given list with the given distance. -
sortAndDedup
public static void sortAndDedup(com.carrotsearch.hppc.ObjectArrayList<byte[]> array) -
sort
public static void sort(com.carrotsearch.hppc.ObjectArrayList<byte[]> array) -
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
-
copyMap
Returns an unmodifiable copy of the given map.- Parameters:
map- Map to copy- Returns:
- unmodifiable copy of the map
-
sort
public static void sort(org.apache.lucene.util.BytesRefArray bytes, int[] indices) -
sortAndDedup
public static int sortAndDedup(org.apache.lucene.util.BytesRefArray bytes, int[] indices) -
iterableAsArrayList
-
arrayAsArrayList
-
asArrayList
-
asArrayList
-
appendToCopy
Creates a copy of the given collection with the given element appended.- Parameters:
collection- collection to copyelement- element to append
-
newSingletonArrayList
-
eagerPartition
-
concatLists
-
wrapUnmodifiableOrEmptySingleton
-