Class StreamUtils


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.stream.Collector<T,​java.util.List<T>,​java.util.List<T>> batchCollector​(int batchSize, java.util.function.Consumer<java.util.List<T>> batchProcessor)
      Creates a new batch collector
      static <X,​Y>
      java.util.stream.Stream<Y>
      ofType​(java.util.Collection<X> items, java.lang.Class<Y> clazz)  
      static <X,​Y>
      java.util.stream.Stream<Y>
      ofType​(java.util.stream.Stream<X> stream, java.lang.Class<Y> clazz)  
      static <T> java.util.stream.Collector<T,​?,​T> single()  
      • Methods inherited from class java.lang.Object

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

      • batchCollector

        public static <T> java.util.stream.Collector<T,​java.util.List<T>,​java.util.List<T>> batchCollector​(int batchSize,
                                                                                                                       java.util.function.Consumer<java.util.List<T>> batchProcessor)
        Creates a new batch collector
        Type Parameters:
        T - the type of elements being processed
        Parameters:
        batchSize - the batch size after which the batchProcessor should be called
        batchProcessor - the batch processor which accepts batches of records to process
        Returns:
        a batch collector instance
      • ofType

        public static <X,​Y> java.util.stream.Stream<Y> ofType​(java.util.Collection<X> items,
                                                                    java.lang.Class<Y> clazz)
      • ofType

        public static <X,​Y> java.util.stream.Stream<Y> ofType​(java.util.stream.Stream<X> stream,
                                                                    java.lang.Class<Y> clazz)
      • single

        public static <T> java.util.stream.Collector<T,​?,​T> single()