Class CollectionUtils

org.elasticsearch.common.util.CollectionUtils

public class CollectionUtils extends
Collections-related utility methods.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <E> <E>
    <E> collection, E element)
    Creates a copy of the given collection with the given element appended.
    static <E> <E>
    arrayAsArrayList​(E... elements)
     
    static <E> <E>
    asArrayList​(E first, E... other)
     
    static <E> <E>
    asArrayList​(E first, E second, E... other)
     
    static <R,​ T> <R,​T>
    <R,​T> map)
    Returns an unmodifiable copy of the given map.
    static <E> <<E>>
    <E> list, int size)
     
    static void
     value,  messageHint)
    Deeply inspects a Map, Iterable, or Object array looking for references back to itself.
    static boolean
    [] array)
    Checks if the given array contains any elements.
    static <E> <E>
    <? extends E> elements)
     
    static <E> <E>
    newSingletonArrayList​(E element)
     
    static <T> <T>
    <T> list, int distance)
    Return a rotated view of the given list with the given distance.
    static void
    sort​(com.carrotsearch.hppc.ObjectArrayList<byte[]> array)
     
    static void
    sort​(org.apache.lucene.util.BytesRefArray bytes, int[] indices)
     
    static void
    sortAndDedup​(com.carrotsearch.hppc.ObjectArrayList<byte[]> array)
     
    static int
    sortAndDedup​(org.apache.lucene.util.BytesRefArray bytes, int[] indices)
     
    static int[]
    <> ints)
     

    Methods inherited from class java.lang.

    , , , , , , , , , ,
  • Constructor Details

    • CollectionUtils

      public CollectionUtils()
  • Method Details

    • isEmpty

      public static boolean isEmpty([] array)
      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

      public static <T> <T> rotate(<T> list, int distance)
      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

      public static int[] toArray(<> ints)
    • ensureNoSelfReferences

      public static void ensureNoSelfReferences( value,  messageHint)
      Deeply inspects a Map, Iterable, or Object array looking for references back to itself.
      Parameters:
      value - The object to evaluate looking for self references
      messageHint - A string to be included in the exception message if the call fails, to provide more context to the handler of the exception
      Throws:
      - if a self-reference is found
    • copyMap

      public static <R,​ T> <R,​T> copyMap(<R,​T> map)
      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

      public static <E> <E> iterableAsArrayList(<? extends E> elements)
    • arrayAsArrayList

      public static <E> <E> arrayAsArrayList(E... elements)
    • asArrayList

      public static <E> <E> asArrayList(E first, E... other)
    • asArrayList

      public static <E> <E> asArrayList(E first, E second, E... other)
    • appendToCopy

      public static <E> <E> appendToCopy(<E> collection, E element)
      Creates a copy of the given collection with the given element appended.
      Parameters:
      collection - collection to copy
      element - element to append
    • newSingletonArrayList

      public static <E> <E> newSingletonArrayList(E element)
    • eagerPartition

      public static <E> <<E>> eagerPartition(<E> list, int size)