Package org.jobrunr.utils.streams
Class StreamUtils
- java.lang.Object
-
- org.jobrunr.utils.streams.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 collectorstatic <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()
-
-
-
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 calledbatchProcessor
- 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()
-
-