Class IterableUtils


  • public class IterableUtils
    extends Object
    A collection of utilities that expand the usage of Iterable.
    • Method Detail

      • toStream

        public static <E> Stream<E> toStream​(Iterable<E> iterable)
        Convert the given Iterable to a Stream.
        Type Parameters:
        E - type of the elements of the iterable
        Parameters:
        iterable - to convert to a stream
        Returns:
        stream converted from the given Iterable
      • flatMap

        @Internal
        public static <K,​V,​G extends Iterable<K>> Iterable<V> flatMap​(Iterable<G> itemGroups,
                                                                                  Function<K,​V> mapper)
        Flatmap the two-dimensional Iterable into an one-dimensional Iterable and convert the keys into items.
        Type Parameters:
        K - type of key in the two-dimensional iterable
        V - type of items that are mapped to
        G - iterable of IterableUtils
        Parameters:
        itemGroups - to flatmap
        mapper - convert the IterableUtils into IterableUtils
        Returns:
        flattened one-dimensional Iterable from the given two-dimensional Iterable