com.datumbox.framework.common.concurrency
Class ForkJoinStream
- java.lang.Object
-
- com.datumbox.framework.common.concurrency.ForkJoinStream
-
public class ForkJoinStream extends java.lang.ObjectThis class can be used to process a Stream in parallel using a custom ForkJoinPool.
-
-
Constructor Summary
Constructors Constructor and Description ForkJoinStream(ConcurrencyConfiguration concurrencyConfiguration)Default constructor which receives the Concurrency Configuration object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description <T,R,A> Rcollect(java.util.stream.Stream<T> stream, java.util.stream.Collector<? super T,A,R> collector)Executes collect on the provided stream using the provided collector.<T> voidforEach(java.util.stream.Stream<T> stream, java.util.function.Consumer<? super T> action)Executes forEach on the provided stream.<T,R> java.util.stream.Stream<R>map(java.util.stream.Stream<T> stream, java.util.function.Function<? super T,? extends R> mapper)Executes map on the provided stream.<T> java.util.Optional<T>max(java.util.stream.Stream<T> stream, java.util.Comparator<? super T> comparator)Executes max on the provided stream using the provided collector.<T> java.util.Optional<T>min(java.util.stream.Stream<T> stream, java.util.Comparator<? super T> comparator)Executes min on the provided stream using the provided collector.doublesum(java.util.stream.DoubleStream stream)Executes sum on the provided DoubleStream using the provided collector.
-
-
-
Constructor Detail
-
ForkJoinStream
public ForkJoinStream(ConcurrencyConfiguration concurrencyConfiguration)
Default constructor which receives the Concurrency Configuration object.- Parameters:
concurrencyConfiguration-
-
-
Method Detail
-
forEach
public <T> void forEach(java.util.stream.Stream<T> stream, java.util.function.Consumer<? super T> action)Executes forEach on the provided stream. If the Stream is parallel, it is executed using the custom pool, else it is executed directly from the main thread.- Type Parameters:
T-- Parameters:
stream-action-
-
map
public <T,R> java.util.stream.Stream<R> map(java.util.stream.Stream<T> stream, java.util.function.Function<? super T,? extends R> mapper)Executes map on the provided stream. If the Stream is parallel, it is executed using the custom pool, else it is executed directly from the main thread.- Type Parameters:
T-R-- Parameters:
stream-mapper-- Returns:
-
collect
public <T,R,A> R collect(java.util.stream.Stream<T> stream, java.util.stream.Collector<? super T,A,R> collector)Executes collect on the provided stream using the provided collector. If the Stream is parallel, it is executed using the custom pool, else it is executed directly from the main thread.- Type Parameters:
T-R-A-- Parameters:
stream-collector-- Returns:
-
min
public <T> java.util.Optional<T> min(java.util.stream.Stream<T> stream, java.util.Comparator<? super T> comparator)Executes min on the provided stream using the provided collector. If the Stream is parallel, it is executed using the custom pool, else it is executed directly from the main thread.- Type Parameters:
T-- Parameters:
stream-comparator-- Returns:
-
max
public <T> java.util.Optional<T> max(java.util.stream.Stream<T> stream, java.util.Comparator<? super T> comparator)Executes max on the provided stream using the provided collector. If the Stream is parallel, it is executed using the custom pool, else it is executed directly from the main thread.- Type Parameters:
T-- Parameters:
stream-comparator-- Returns:
-
sum
public double sum(java.util.stream.DoubleStream stream)
Executes sum on the provided DoubleStream using the provided collector. If the Stream is parallel, it is executed using the custom pool, else it is executed directly from the main thread.- Parameters:
stream-- Returns:
-
-
DataMelt 3.0 © DataMelt by jWork.ORG