Class CollectionUtils


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

      Constructors 
      Constructor Description
      CollectionUtils()  
    • Method Summary

      Modifier and Type Method Description
      static <E> java.util.ArrayList<E> arrayAsArrayList​(E... elements)  
      static <E> java.util.ArrayList<E> asArrayList​(E first, E... other)  
      static <E> java.util.ArrayList<E> asArrayList​(E first, E second, E... other)  
      static <E> java.util.List<java.util.List<E>> eagerPartition​(java.util.List<E> list, int size)  
      static void ensureNoSelfReferences​(java.lang.Object value, java.lang.String messageHint)
      Deeply inspects a Map, Iterable, or Object array looking for references back to itself.
      static boolean isEmpty​(java.lang.Object[] array)
      Checks if the given array contains any elements.
      static <E> java.util.ArrayList<E> iterableAsArrayList​(java.lang.Iterable<? extends E> elements)  
      static <E> java.util.ArrayList<E> newSingletonArrayList​(E element)  
      static <T> java.util.List<T> rotate​(java.util.List<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[] toArray​(java.util.Collection<java.lang.Integer> ints)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CollectionUtils

        public CollectionUtils()
    • Method Detail

      • isEmpty

        public static boolean isEmpty​(java.lang.Object[] 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> java.util.List<T> rotate​(java.util.List<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​(java.util.Collection<java.lang.Integer> ints)
      • ensureNoSelfReferences

        public static void ensureNoSelfReferences​(java.lang.Object value,
                                                  java.lang.String 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:
        java.lang.IllegalArgumentException - if a self-reference is found
      • 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> java.util.ArrayList<E> iterableAsArrayList​(java.lang.Iterable<? extends E> elements)
      • arrayAsArrayList

        public static <E> java.util.ArrayList<E> arrayAsArrayList​(E... elements)
      • asArrayList

        public static <E> java.util.ArrayList<E> asArrayList​(E first,
                                                             E... other)
      • asArrayList

        public static <E> java.util.ArrayList<E> asArrayList​(E first,
                                                             E second,
                                                             E... other)
      • newSingletonArrayList

        public static <E> java.util.ArrayList<E> newSingletonArrayList​(E element)
      • eagerPartition

        public static <E> java.util.List<java.util.List<E>> eagerPartition​(java.util.List<E> list,
                                                                           int size)