Class Collectors
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
The set of variance statistic types. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaveragingDouble
(ToDoubleFunction<? super T> mapper) Functionally transparent version ofCollectors.averagingDouble(ToDoubleFunction)
averagingInt
(ToIntFunction<? super T> mapper) Functionally transparent version ofCollectors.averagingInt(ToIntFunction)
averagingLong
(ToLongFunction<? super T> mapper) Functionally transparent version ofCollectors.averagingLong(ToLongFunction)
static <T,
A, R, RR> Collector<T, A, RR> collectingAndThen
(Collector<T, A, R> downstream, Function<R, RR> finisher) Functionally transparent version ofCollectors.collectingAndThen(Collector, Function)
Runs a list ofCollector
s accepting elements of typeU
in parallel against the same sequence of elements.counting()
Functionally transparent version ofCollectors.counting()
static <T,
A, R> Collector<T, A, R> Functionally transparent version ofjava.util.stream.Collectors.filtering(Predicate, Collector)
(a method added in Java 9).groupingBy
(Function<? super T, ? extends K> classifier, Collector<? super T, A, D> downstream) Functionally transparent version ofCollectors.groupingBy(Function, Collector)
static <T,
K, A, D> Collector<T, ?, ConcurrentMap<K, D>> groupingByConcurrent
(Function<? super T, ? extends K> classifier, Collector<? super T, A, D> downstream) Functionally transparent version ofCollectors.groupingByConcurrent(Function, Collector)
static <T,
U, A, R> Collector<T, ?, R> Functionally transparent version ofCollectors.mapping(Function, Collector)
maxBy
(Comparator<? super T> comparator) Functionally transparent version ofCollectors.maxBy(Comparator)
minBy
(Comparator<? super T> comparator) Functionally transparent version ofCollectors.minBy(Comparator)
partitioningBy
(Predicate<? super T> predicate, Collector<? super T, A, D> downstream) Functionally transparent version ofCollectors.partitioningBy(Predicate, Collector)
static <T> Collector<T,
?, DoubleSummaryStatistics> summarizingDouble
(ToDoubleFunction<? super T> mapper) Functionally transparent version ofCollectors.summarizingDouble(ToDoubleFunction)
static <T> Collector<T,
?, IntSummaryStatistics> summarizingInt
(ToIntFunction<? super T> mapper) Functionally transparent version ofCollectors.summarizingInt(ToIntFunction)
static <T> Collector<T,
?, LongSummaryStatistics> summarizingLong
(ToLongFunction<? super T> mapper) Functionally transparent version ofCollectors.summarizingLong(ToLongFunction)
summingDouble
(ToDoubleFunction<? super T> mapper) Functionally transparent version ofCollectors.summingDouble(ToDoubleFunction)
summingInt
(ToIntFunction<? super T> mapper) Functionally transparent version ofCollectors.summingInt(ToIntFunction)
summingLong
(ToLongFunction<? super T> mapper) Functionally transparent version ofCollectors.summingLong(ToLongFunction)
toSet()
Functionally transparent version ofCollectors.toSet()
varianceOf
(ToDoubleFunction<T> mapper, Collectors.VarianceType type) Deprecated.varianceOf
(ToIntFunction<T> mapper, Collectors.VarianceType type) Deprecated.in favor ofvarianceOfInt(ToIntFunction, VarianceType)
varianceOf
(ToLongFunction<T> mapper, Collectors.VarianceType type) Deprecated.in favor ofvarianceOfLong(ToLongFunction, VarianceType)
varianceOfDouble
(ToDoubleFunction<T> mapper, Collectors.VarianceType type) Returns aCollector
that produces the statistical variance of a double-valued function applied to the input elements.varianceOfInt
(ToIntFunction<T> mapper, Collectors.VarianceType type) Returns aCollector
that produces the statistical variance of an integer-valued function applied to the input elements.varianceOfLong
(ToLongFunction<T> mapper, Collectors.VarianceType type) Returns aCollector
that produces the statistical variance of a long-valued function applied to the input elements.
-
Constructor Details
-
Collectors
public Collectors()
-
-
Method Details
-
composite
@SafeVarargs public static <T> Collector<T,List<Object>, compositeList<Object>> (Collector<T, ?, ?>... collectors) Runs a list ofCollector
s accepting elements of typeU
in parallel against the same sequence of elements.- Type Parameters:
T
- the type of the input elements- Parameters:
collectors
- a list of downstream collectors which will accept the elements- Returns:
- a collector which provides the elements to all the downstream collectors
-
filtering
public static <T,A, Collector<T,R> A, filteringR> (Predicate<? super T> predicate, Collector<T, A, R> downstream) Functionally transparent version ofjava.util.stream.Collectors.filtering(Predicate, Collector)
(a method added in Java 9).- Type Parameters:
T
- the type of the input elementsA
- intermediate accumulation type of the downstream collectorR
- result type of collector- Parameters:
predicate
- a predicate to be applied to the input elementsdownstream
- a collector which will accept values that match the predicate- Returns:
- a collector which applies the predicate to the input elements and provides matching elements to the downstream collector
-
mapping
public static <T,U, Collector<T,A, R> ?, mappingR> (Function<? super T, ? extends U> mapper, Collector<? super U, A, R> downstream) Functionally transparent version ofCollectors.mapping(Function, Collector)
- Type Parameters:
T
- the type of the input elementsU
- type of elements accepted by downstream collectorA
- intermediate accumulation type of the downstream collectorR
- result type of collector- Parameters:
mapper
- a function to be applied to the input elementsdownstream
- a collector which will accept mapped values- Returns:
- a collector which applies the mapping function to the input elements and provides the mapped results to the downstream collector
-
counting
Functionally transparent version ofCollectors.counting()
- Type Parameters:
T
- the type of the input elements- Returns:
- a
Collector
that counts the input elements
-
minBy
Functionally transparent version ofCollectors.minBy(Comparator)
- Type Parameters:
T
- the type of the input elements- Parameters:
comparator
- aComparator
for comparing elements- Returns:
- a
Collector
that produces the minimal value
-
maxBy
Functionally transparent version ofCollectors.maxBy(Comparator)
- Type Parameters:
T
- the type of the input elements- Parameters:
comparator
- aComparator
for comparing elements- Returns:
- a
Collector
that produces the maximal value
-
summingInt
Functionally transparent version ofCollectors.summingInt(ToIntFunction)
- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a function extracting the property to be summed- Returns:
- a
Collector
that produces the sum of a derived property
-
summingLong
Functionally transparent version ofCollectors.summingLong(ToLongFunction)
- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a function extracting the property to be summed- Returns:
- a
Collector
that produces the sum of a derived property
-
summingDouble
Functionally transparent version ofCollectors.summingDouble(ToDoubleFunction)
- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a function extracting the property to be summed- Returns:
- a
Collector
that produces the sum of a derived property
-
averagingInt
Functionally transparent version ofCollectors.averagingInt(ToIntFunction)
- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a function extracting the property to be summed- Returns:
- a
Collector
that produces the mean of a derived property
-
averagingLong
Functionally transparent version ofCollectors.averagingLong(ToLongFunction)
- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a function extracting the property to be summed- Returns:
- a
Collector
that produces the mean of a derived property
-
averagingDouble
Functionally transparent version ofCollectors.averagingDouble(ToDoubleFunction)
- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a function extracting the property to be summed- Returns:
- a
Collector
that produces the mean of a derived property
-
groupingBy
public static <T,K, Collector<T,A, D> ?, groupingByMap<K, D>> (Function<? super T, ? extends K> classifier, Collector<? super T, A, D> downstream) Functionally transparent version ofCollectors.groupingBy(Function, Collector)
- Type Parameters:
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 reduction- Parameters:
classifier
- a classifier function mapping input elements to keysdownstream
- aCollector
implementing the downstream reduction- Returns:
- a
Collector
implementing the cascaded group-by operation
-
groupingByConcurrent
public static <T,K, Collector<T,A, D> ?, groupingByConcurrentConcurrentMap<K, D>> (Function<? super T, ? extends K> classifier, Collector<? super T, A, D> downstream) Functionally transparent version ofCollectors.groupingByConcurrent(Function, Collector)
- Type Parameters:
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 reduction- Parameters:
classifier
- a classifier function mapping input elements to keysdownstream
- aCollector
implementing the downstream reduction- Returns:
- a concurrent, unordered
Collector
implementing the cascaded group-by operation
-
partitioningBy
public static <T,D, Collector<T,A> ?, partitioningByMap<Boolean, D>> (Predicate<? super T> predicate, Collector<? super T, A, D> downstream) Functionally transparent version ofCollectors.partitioningBy(Predicate, Collector)
- Type Parameters:
T
- the type of the input elementsA
- the intermediate accumulation type of the downstream collectorD
- the result type of the downstream reduction- Parameters:
predicate
- a predicate used for classifying input elementsdownstream
- aCollector
implementing the downstream reduction- Returns:
- a
Collector
implementing the cascaded partitioning operation
-
summarizingInt
public static <T> Collector<T,?, summarizingIntIntSummaryStatistics> (ToIntFunction<? super T> mapper) Functionally transparent version ofCollectors.summarizingInt(ToIntFunction)
- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a mapping function to apply to each element- Returns:
- a
Collector
implementing the summary-statistics reduction
-
summarizingLong
public static <T> Collector<T,?, summarizingLongLongSummaryStatistics> (ToLongFunction<? super T> mapper) Functionally transparent version ofCollectors.summarizingLong(ToLongFunction)
- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a mapping function to apply to each element- Returns:
- a
Collector
implementing the summary-statistics reduction
-
summarizingDouble
public static <T> Collector<T,?, summarizingDoubleDoubleSummaryStatistics> (ToDoubleFunction<? super T> mapper) Functionally transparent version ofCollectors.summarizingDouble(ToDoubleFunction)
- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a mapping function to apply to each element- Returns:
- a
Collector
implementing the summary-statistics reduction
-
toSet
Functionally transparent version ofCollectors.toSet()
- Type Parameters:
T
- the type of the input elements- Returns:
- a
Collector
which collects all the input elements into aSet
-
collectingAndThen
public static <T,A, Collector<T,R, RR> A, collectingAndThenRR> (Collector<T, A, R> downstream, Function<R, RR> finisher) Functionally transparent version ofCollectors.collectingAndThen(Collector, Function)
- Type Parameters:
T
- the type of the input elements- Returns:
- a
Collector
which collects all the input elements into aSet
-
varianceOf
@Deprecated public static <T> Collector<T,?, varianceOfOptional<Double>> (ToIntFunction<T> mapper, Collectors.VarianceType type) Deprecated.in favor ofvarianceOfInt(ToIntFunction, VarianceType)
Returns aCollector
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.- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a function extracting the property to be summedtype
- the requested variance type- Returns:
- a
Collector
that produces the variance of a derived property
-
varianceOfInt
public static <T> Collector<T,?, varianceOfIntOptional<Double>> (ToIntFunction<T> mapper, Collectors.VarianceType type) Returns aCollector
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 isCollectors.VarianceType.POPULATION
and no elements are present, the result is an empty optional. If the variance type isCollectors.VarianceType.SAMPLE
and less than two elements are present, then result is an empty optional.- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a function extracting the property to be summedtype
- the requested variance type- Returns:
- a
Collector
that produces the variance of a derived property
-
varianceOf
@Deprecated public static <T> Collector<T,?, varianceOfOptional<Double>> (ToLongFunction<T> mapper, Collectors.VarianceType type) Deprecated.in favor ofvarianceOfLong(ToLongFunction, VarianceType)
Returns aCollector
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.- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a function extracting the property to be summedtype
- the requested variance type- Returns:
- a
Collector
that produces the variance of a derived property
-
varianceOfLong
public static <T> Collector<T,?, varianceOfLongOptional<Double>> (ToLongFunction<T> mapper, Collectors.VarianceType type) Returns aCollector
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 isCollectors.VarianceType.POPULATION
and no elements are present, the result is an empty optional. If the variance type isCollectors.VarianceType.SAMPLE
and less than two elements are present, then result is an empty optional.- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a function extracting the property to be summedtype
- the requested variance type- Returns:
- a
Collector
that produces the variance of a derived property
-
varianceOf
@Deprecated public static <T> Collector<T,?, varianceOfOptional<Double>> (ToDoubleFunction<T> mapper, Collectors.VarianceType type) Deprecated.in favor ofvarianceOfDouble(ToDoubleFunction, VarianceType)
Returns aCollector
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.- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a function extracting the property to be summedtype
- the requested variance type- Returns:
- a
Collector
that produces the variance of a derived property
-
varianceOfDouble
public static <T> Collector<T,?, varianceOfDoubleOptional<Double>> (ToDoubleFunction<T> mapper, Collectors.VarianceType type) Returns aCollector
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 isCollectors.VarianceType.POPULATION
and no elements are present, the result is an empty optional. If the variance type isCollectors.VarianceType.SAMPLE
and less than two elements are present, then result is an empty optional.- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a function extracting the property to be summedtype
- the requested variance type- Returns:
- a
Collector
that produces the variance of a derived property
-
varianceOfDouble(ToDoubleFunction, VarianceType)