Class CollectionUtil


  • public final class CollectionUtil
    extends Object
    Various helper utilities for Collections.
    • Method Detail

      • addAll

        public static <T> void addAll​(Collection<T> c,
                                      T[] items)
      • toStringArray

        public static <T> String[] toStringArray​(Collection<T> c)
        Returns:
        String[]
      • getSingleton

        public static <T> T getSingleton​(Collection<T> s)
      • addArray

        public static <T> void addArray​(Collection<T> c,
                                        T[] array)
        Add all items in an array to a set.
      • toArray

        public static <T> T[] toArray​(Collection<? extends T> c,
                                      Class<T> elementClass)
        Parameters:
        c - the Collection
        elementClass - the type of the element, must be non-primitive
        Returns:
        array of [] elements
      • isAllStrings

        public static boolean isAllStrings​(Collection<?> c)
        Returns:
        true if all elements are String, and there is at least one element