public final class Collectors
extends java.lang.Object
Collectors
.
The methods in this class provide Collector
implementations that can be optimized by TCStore. The equivalent
java.util.stream.Collectors
methods are functionally-opaque and cannot be optimized by TCStore.
Modifier and Type | Class and Description |
---|---|
static class |
Collectors.VarianceType
The set of variance statistic types.
|
Constructor and Description |
---|
Collectors() |
Modifier and Type | Method and Description |
---|---|
static <T> java.util.stream.Collector<T,?,java.lang.Double> |
averagingDouble(java.util.function.ToDoubleFunction<? super T> mapper)
Functionally transparent version of
Collectors.averagingDouble(ToDoubleFunction) |
static <T> java.util.stream.Collector<T,?,java.lang.Double> |
averagingInt(java.util.function.ToIntFunction<? super T> mapper)
Functionally transparent version of
Collectors.averagingInt(ToIntFunction) |
static <T> java.util.stream.Collector<T,?,java.lang.Double> |
averagingLong(java.util.function.ToLongFunction<? super T> mapper)
Functionally transparent version of
Collectors.averagingLong(ToLongFunction) |
static <T> java.util.stream.Collector<T,java.util.List<java.lang.Object>,java.util.List<java.lang.Object>> |
composite(java.util.stream.Collector<T,?,?>... collectors)
Runs a list of
Collector s accepting elements of type U in parallel against the same sequence of elements. |
static <T> java.util.stream.Collector<T,?,java.lang.Long> |
counting()
Functionally transparent version of
Collectors.counting() |
static <T,A,R> java.util.stream.Collector<T,A,R> |
filtering(java.util.function.Predicate<? super T> predicate,
java.util.stream.Collector<T,A,R> downstream)
Functionally transparent version of
java.util.stream.Collectors.filtering(Predicate, Collector) (a method added in Java 9). |
static <T,K,A,D> java.util.stream.Collector<T,?,java.util.Map<K,D>> |
groupingBy(java.util.function.Function<? super T,? extends K> classifier,
java.util.stream.Collector<? super T,A,D> downstream)
Functionally transparent version of
Collectors.groupingBy(Function, Collector) |
static <T,K,A,D> java.util.stream.Collector<T,?,java.util.concurrent.ConcurrentMap<K,D>> |
groupingByConcurrent(java.util.function.Function<? super T,? extends K> classifier,
java.util.stream.Collector<? super T,A,D> downstream)
Functionally transparent version of
Collectors.groupingByConcurrent(Function, Collector) |
static <T,U,A,R> java.util.stream.Collector<T,?,R> |
mapping(java.util.function.Function<? super T,? extends U> mapper,
java.util.stream.Collector<? super U,A,R> downstream)
Functionally transparent version of
Collectors.mapping(Function, Collector) |
static <T> java.util.stream.Collector<T,?,java.util.Optional<T>> |
maxBy(java.util.Comparator<? super T> comparator)
Functionally transparent version of
Collectors.maxBy(Comparator) |
static <T> java.util.stream.Collector<T,?,java.util.Optional<T>> |
minBy(java.util.Comparator<? super T> comparator)
Functionally transparent version of
Collectors.minBy(Comparator) |
static <T,D,A> java.util.stream.Collector<T,?,java.util.Map<java.lang.Boolean,D>> |
partitioningBy(java.util.function.Predicate<? super T> predicate,
java.util.stream.Collector<? super T,A,D> downstream)
Functionally transparent version of
Collectors.partitioningBy(Predicate, Collector) |
static <T> java.util.stream.Collector<T,?,java.util.DoubleSummaryStatistics> |
summarizingDouble(java.util.function.ToDoubleFunction<? super T> mapper)
Functionally transparent version of
Collectors.summarizingDouble(ToDoubleFunction) |
static <T> java.util.stream.Collector<T,?,java.util.IntSummaryStatistics> |
summarizingInt(java.util.function.ToIntFunction<? super T> mapper)
Functionally transparent version of
Collectors.summarizingInt(ToIntFunction) |
static <T> java.util.stream.Collector<T,?,java.util.LongSummaryStatistics> |
summarizingLong(java.util.function.ToLongFunction<? super T> mapper)
Functionally transparent version of
Collectors.summarizingLong(ToLongFunction) |
static <T> java.util.stream.Collector<T,?,java.lang.Double> |
summingDouble(java.util.function.ToDoubleFunction<? super T> mapper)
Functionally transparent version of
Collectors.summingDouble(ToDoubleFunction) |
static <T> java.util.stream.Collector<T,?,java.lang.Integer> |
summingInt(java.util.function.ToIntFunction<? super T> mapper)
Functionally transparent version of
Collectors.summingInt(ToIntFunction) |
static <T> java.util.stream.Collector<T,?,java.lang.Long> |
summingLong(java.util.function.ToLongFunction<? super T> mapper)
Functionally transparent version of
Collectors.summingLong(ToLongFunction) |
static <T> java.util.stream.Collector<T,?,java.util.Optional<java.lang.Double>> |
varianceOf(java.util.function.ToDoubleFunction<T> mapper,
Collectors.VarianceType type)
Deprecated.
in favor of
varianceOfDouble(ToDoubleFunction, VarianceType) |
static <T> java.util.stream.Collector<T,?,java.util.Optional<java.lang.Double>> |
varianceOf(java.util.function.ToIntFunction<T> mapper,
Collectors.VarianceType type)
Deprecated.
in favor of
varianceOfInt(ToIntFunction, VarianceType) |
static <T> java.util.stream.Collector<T,?,java.util.Optional<java.lang.Double>> |
varianceOf(java.util.function.ToLongFunction<T> mapper,
Collectors.VarianceType type)
Deprecated.
in favor of
varianceOfLong(ToLongFunction, VarianceType) |
static <T> java.util.stream.Collector<T,?,java.util.Optional<java.lang.Double>> |
varianceOfDouble(java.util.function.ToDoubleFunction<T> mapper,
Collectors.VarianceType type)
Returns a
Collector that produces the statistical variance of a double-valued function applied to the
input elements. |
static <T> java.util.stream.Collector<T,?,java.util.Optional<java.lang.Double>> |
varianceOfInt(java.util.function.ToIntFunction<T> mapper,
Collectors.VarianceType type)
Returns a
Collector that produces the statistical variance of an integer-valued function applied to the
input elements. |
static <T> java.util.stream.Collector<T,?,java.util.Optional<java.lang.Double>> |
varianceOfLong(java.util.function.ToLongFunction<T> mapper,
Collectors.VarianceType type)
Returns a
Collector that produces the statistical variance of a long-valued function applied to the
input elements. |
@SafeVarargs public static <T> java.util.stream.Collector<T,java.util.List<java.lang.Object>,java.util.List<java.lang.Object>> composite(java.util.stream.Collector<T,?,?>... collectors)
Collector
s accepting elements of type U
in parallel against the same sequence of elements.T
- the type of the input elementscollectors
- a list of downstream collectors which will accept the elementspublic static <T,A,R> java.util.stream.Collector<T,A,R> filtering(java.util.function.Predicate<? super T> predicate, java.util.stream.Collector<T,A,R> downstream)
java.util.stream.Collectors.filtering(Predicate, Collector)
(a method added in Java 9).T
- the type of the input elementsA
- intermediate accumulation type of the downstream collectorR
- result type of collectorpredicate
- a predicate to be applied to the input elementsdownstream
- a collector which will accept values that match the predicatepublic static <T,U,A,R> java.util.stream.Collector<T,?,R> mapping(java.util.function.Function<? super T,? extends U> mapper, java.util.stream.Collector<? super U,A,R> downstream)
Collectors.mapping(Function, Collector)
T
- the type of the input elementsU
- type of elements accepted by downstream collectorA
- intermediate accumulation type of the downstream collectorR
- result type of collectormapper
- a function to be applied to the input elementsdownstream
- a collector which will accept mapped valuespublic static <T> java.util.stream.Collector<T,?,java.lang.Long> counting()
Collectors.counting()
T
- the type of the input elementsCollector
that counts the input elementspublic static <T> java.util.stream.Collector<T,?,java.util.Optional<T>> minBy(java.util.Comparator<? super T> comparator)
Collectors.minBy(Comparator)
T
- the type of the input elementscomparator
- a Comparator
for comparing elementsCollector
that produces the minimal valuepublic static <T> java.util.stream.Collector<T,?,java.util.Optional<T>> maxBy(java.util.Comparator<? super T> comparator)
Collectors.maxBy(Comparator)
T
- the type of the input elementscomparator
- a Comparator
for comparing elementsCollector
that produces the maximal valuepublic static <T> java.util.stream.Collector<T,?,java.lang.Integer> summingInt(java.util.function.ToIntFunction<? super T> mapper)
Collectors.summingInt(ToIntFunction)
T
- the type of the input elementsmapper
- a function extracting the property to be summedCollector
that produces the sum of a derived propertypublic static <T> java.util.stream.Collector<T,?,java.lang.Long> summingLong(java.util.function.ToLongFunction<? super T> mapper)
Collectors.summingLong(ToLongFunction)
T
- the type of the input elementsmapper
- a function extracting the property to be summedCollector
that produces the sum of a derived propertypublic static <T> java.util.stream.Collector<T,?,java.lang.Double> summingDouble(java.util.function.ToDoubleFunction<? super T> mapper)
Collectors.summingDouble(ToDoubleFunction)
T
- the type of the input elementsmapper
- a function extracting the property to be summedCollector
that produces the sum of a derived propertypublic static <T> java.util.stream.Collector<T,?,java.lang.Double> averagingInt(java.util.function.ToIntFunction<? super T> mapper)
Collectors.averagingInt(ToIntFunction)
T
- the type of the input elementsmapper
- a function extracting the property to be summedCollector
that produces the mean of a derived propertypublic static <T> java.util.stream.Collector<T,?,java.lang.Double> averagingLong(java.util.function.ToLongFunction<? super T> mapper)
Collectors.averagingLong(ToLongFunction)
T
- the type of the input elementsmapper
- a function extracting the property to be summedCollector
that produces the mean of a derived propertypublic static <T> java.util.stream.Collector<T,?,java.lang.Double> averagingDouble(java.util.function.ToDoubleFunction<? super T> mapper)
Collectors.averagingDouble(ToDoubleFunction)
T
- the type of the input elementsmapper
- a function extracting the property to be summedCollector
that produces the mean of a derived propertypublic static <T,K,A,D> java.util.stream.Collector<T,?,java.util.Map<K,D>> groupingBy(java.util.function.Function<? super T,? extends K> classifier, java.util.stream.Collector<? super T,A,D> downstream)
Collectors.groupingBy(Function, Collector)
T
- the type of the input elementsK
- the type of the keysA
- the intermediate accumulation type of the downstream collectorD
- the result type of the downstream reductionclassifier
- a classifier function mapping input elements to keysdownstream
- a Collector
implementing the downstream reductionCollector
implementing the cascaded group-by operationpublic static <T,K,A,D> java.util.stream.Collector<T,?,java.util.concurrent.ConcurrentMap<K,D>> groupingByConcurrent(java.util.function.Function<? super T,? extends K> classifier, java.util.stream.Collector<? super T,A,D> downstream)
Collectors.groupingByConcurrent(Function, Collector)
T
- the type of the input elementsK
- the type of the keysA
- the intermediate accumulation type of the downstream collectorD
- the result type of the downstream reductionclassifier
- a classifier function mapping input elements to keysdownstream
- a Collector
implementing the downstream reductionCollector
implementing the cascaded group-by operationpublic static <T,D,A> java.util.stream.Collector<T,?,java.util.Map<java.lang.Boolean,D>> partitioningBy(java.util.function.Predicate<? super T> predicate, java.util.stream.Collector<? super T,A,D> downstream)
Collectors.partitioningBy(Predicate, Collector)
T
- the type of the input elementsA
- the intermediate accumulation type of the downstream collectorD
- the result type of the downstream reductionpredicate
- a predicate used for classifying input elementsdownstream
- a Collector
implementing the downstream reductionCollector
implementing the cascaded partitioning operationpublic static <T> java.util.stream.Collector<T,?,java.util.IntSummaryStatistics> summarizingInt(java.util.function.ToIntFunction<? super T> mapper)
Collectors.summarizingInt(ToIntFunction)
T
- the type of the input elementsmapper
- a mapping function to apply to each elementCollector
implementing the summary-statistics reductionpublic static <T> java.util.stream.Collector<T,?,java.util.LongSummaryStatistics> summarizingLong(java.util.function.ToLongFunction<? super T> mapper)
Collectors.summarizingLong(ToLongFunction)
T
- the type of the input elementsmapper
- a mapping function to apply to each elementCollector
implementing the summary-statistics reductionpublic static <T> java.util.stream.Collector<T,?,java.util.DoubleSummaryStatistics> summarizingDouble(java.util.function.ToDoubleFunction<? super T> mapper)
Collectors.summarizingDouble(ToDoubleFunction)
T
- the type of the input elementsmapper
- a mapping function to apply to each elementCollector
implementing the summary-statistics reduction@Deprecated public static <T> java.util.stream.Collector<T,?,java.util.Optional<java.lang.Double>> varianceOf(java.util.function.ToIntFunction<T> mapper, Collectors.VarianceType type)
varianceOfInt(ToIntFunction, VarianceType)
Collector
that produces the statistical variance of an integer-valued function applied to the
input elements.
This method is deprecated in favor of varianceOfInt(ToIntFunction, VarianceType)
as this method is
overloaded in an ambiguous manner by the other type variant variance collector methods.
T
- the type of the input elementsmapper
- a function extracting the property to be summedtype
- the requested variance typeCollector
that produces the variance of a derived propertypublic static <T> java.util.stream.Collector<T,?,java.util.Optional<java.lang.Double>> varianceOfInt(java.util.function.ToIntFunction<T> mapper, Collectors.VarianceType type)
Collector
that produces the statistical variance of an integer-valued function applied to the
input elements.
Population or sample variance can be selected using the type
argument.
If the variance type is Collectors.VarianceType.POPULATION
and no elements are present, the result is an empty optional.
If the variance type is Collectors.VarianceType.SAMPLE
and less than two elements are present, then result is an empty optional.
T
- the type of the input elementsmapper
- a function extracting the property to be summedtype
- the requested variance typeCollector
that produces the variance of a derived property@Deprecated public static <T> java.util.stream.Collector<T,?,java.util.Optional<java.lang.Double>> varianceOf(java.util.function.ToLongFunction<T> mapper, Collectors.VarianceType type)
varianceOfLong(ToLongFunction, VarianceType)
Collector
that produces the statistical variance of a long-valued function applied to the
input elements.
This method is deprecated in favor of varianceOfLong(ToLongFunction, VarianceType)
as this method is
overloaded in an ambiguous manner by the other type variant variance collector methods.
T
- the type of the input elementsmapper
- a function extracting the property to be summedtype
- the requested variance typeCollector
that produces the variance of a derived propertypublic static <T> java.util.stream.Collector<T,?,java.util.Optional<java.lang.Double>> varianceOfLong(java.util.function.ToLongFunction<T> mapper, Collectors.VarianceType type)
Collector
that produces the statistical variance of a long-valued function applied to the
input elements.
Population or sample variance can be selected using the type
argument.
If the variance type is Collectors.VarianceType.POPULATION
and no elements are present, the result is an empty optional.
If the variance type is Collectors.VarianceType.SAMPLE
and less than two elements are present, then result is an empty optional.
T
- the type of the input elementsmapper
- a function extracting the property to be summedtype
- the requested variance typeCollector
that produces the variance of a derived property@Deprecated public static <T> java.util.stream.Collector<T,?,java.util.Optional<java.lang.Double>> varianceOf(java.util.function.ToDoubleFunction<T> mapper, Collectors.VarianceType type)
varianceOfDouble(ToDoubleFunction, VarianceType)
Collector
that produces the statistical variance of a double-valued function applied to the
input elements.
This method is deprecated in favor of varianceOfDouble(ToDoubleFunction, VarianceType)
as this method is
overloaded in an ambiguous manner by the other type variant variance collector methods.
T
- the type of the input elementsmapper
- a function extracting the property to be summedtype
- the requested variance typeCollector
that produces the variance of a derived propertypublic static <T> java.util.stream.Collector<T,?,java.util.Optional<java.lang.Double>> varianceOfDouble(java.util.function.ToDoubleFunction<T> mapper, Collectors.VarianceType type)
Collector
that produces the statistical variance of a double-valued function applied to the
input elements.
Population or sample variance can be selected using the type
argument.
If the variance type is Collectors.VarianceType.POPULATION
and no elements are present, the result is an empty optional.
If the variance type is Collectors.VarianceType.SAMPLE
and less than two elements are present, then result is an empty optional.
T
- the type of the input elementsmapper
- a function extracting the property to be summedtype
- the requested variance typeCollector
that produces the variance of a derived property