Class CollectionUtils


  • public final class CollectionUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> void addAll​(java.util.Iterator<T> iterator, java.util.Collection<T> collection)
      Add all items from the iterator to the collection.
      static <T> T[] concat​(T t, T[] ts)
      Return a new array which contains
      static <T> boolean contains​(T[] ts, T t)
      Return true, if the given array
      static <I> java.util.List<I> iteratorToList​(java.util.Iterator<I> iterator)
      Return all items returned by the Iterator as a List.
      • Methods inherited from class java.lang.Object

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

      • iteratorToList

        @Nonnull
        public static <I> java.util.List<I> iteratorToList​(@Nonnull
                                                           java.util.Iterator<I> iterator)
        Return all items returned by the Iterator as a List.
        Type Parameters:
        I - type
        Parameters:
        iterator - iterator
        Returns:
        list
      • concat

        @Nonnull
        public static <T> T[] concat​(@Nonnull
                                     T t,
                                     @Nonnull
                                     T[] ts)
        Return a new array which contains
        t
        as first element, followed by the elements of
        ts
        .
        Type Parameters:
        T - type
        Parameters:
        t - head
        ts - tail
        Returns:
        t and ts as array
      • contains

        public static <T> boolean contains​(@Nonnull
                                           T[] ts,
                                           @Nonnull
                                           T t)
        Return true, if the given array
        ts
        contains the element
        t
        .
        Type Parameters:
        T - type
        Parameters:
        ts - elements
        t - searched element
        Returns:
        true if ts contains t, false otherwise
      • addAll

        public static <T> void addAll​(@Nonnull
                                      java.util.Iterator<T> iterator,
                                      @Nonnull
                                      java.util.Collection<T> collection)
        Add all items from the iterator to the collection.
        Type Parameters:
        T - type of item
        Parameters:
        iterator - iterator to gather items from
        collection - collection to add items to