Class ExtraCollectors


  • public class ExtraCollectors
    extends java.lang.Object
    Extra collector utilities.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.stream.Collector<T,​java.util.LinkedList<java.util.List<T>>,​java.util.stream.Stream<java.util.List<T>>> inBatchesOf​(int itemsPerBatch)
      Collect into batches of max N items per batch.
      static <T> java.util.stream.Collector<T,​java.util.ArrayList<java.util.List<T>>,​java.util.stream.Stream<java.util.List<T>>> inNumBatches​(int numBatches)
      Collect into N batches of approximate equal size.
      • Methods inherited from class java.lang.Object

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

      • inBatchesOf

        public static <T> java.util.stream.Collector<T,​java.util.LinkedList<java.util.List<T>>,​java.util.stream.Stream<java.util.List<T>>> inBatchesOf​(int itemsPerBatch)
        Collect into batches of max N items per batch. Creates a stream of lists as response.
        Type Parameters:
        T - The item type.
        Parameters:
        itemsPerBatch - Maximum number of items per batch.
        Returns:
        The stream of batched entries.
      • inNumBatches

        public static <T> java.util.stream.Collector<T,​java.util.ArrayList<java.util.List<T>>,​java.util.stream.Stream<java.util.List<T>>> inNumBatches​(int numBatches)
        Collect into N batches of approximate equal size. Creates a stream of lists as response.
        Type Parameters:
        T - The item type.
        Parameters:
        numBatches - Number of batch to split between.
        Returns:
        The stream of batched entries.