Class StreamUtils
- java.lang.Object
-
- cn.boboweike.carrot.utils.streams.StreamUtils
-
public final class StreamUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Collector<T,List<T>,List<T>>batchCollector(int batchSize, Consumer<List<T>> batchProcessor)Creates a new batch collectorstatic <X,Y>
Stream<Y>ofType(Collection<X> items, Class<Y> clazz)static <X,Y>
Stream<Y>ofType(Stream<X> stream, Class<Y> clazz)static <T> Collector<T,?,T>single()
-
-
-
Method Detail
-
batchCollector
public static <T> Collector<T,List<T>,List<T>> batchCollector(int batchSize, Consumer<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> Stream<Y> ofType(Collection<X> items, Class<Y> clazz)
-
single
public static <T> Collector<T,?,T> single()
-
-