栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

第四篇 JDK11 Collectors预置的收集器方法

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

第四篇 JDK11 Collectors预置的收集器方法

java.util.stream.Collectors

修饰符和类型方法描述
static  CollectoraveragingDouble​(ToDoubleFunction mapper)

返回求输入Double类型元素平均值的Collector

static  CollectoraveragingInt​(ToIntFunction mapper)返回求输入Interger类型元素平均值的Collector
static  CollectoraveragingLong​(ToLongFunction mapper)返回求输入Long类型元素平均值的Collector
static
Collector
collectingAndThen​(Collector downstream, Function finisher)

调整收集器在完成收集后应用额外的转换逻辑

static  Collectorcounting()

返回一个接受T类型元素的Collector,用于统计T元素的个数

static
Collector
filtering​(Predicate predicate, Collector downstream)通过对每个输入元素应用Predicate,使收集器适应于一个接受相同类型T的元素,并只在Predicate返回true时进行累积。  
static
Collector
flatMapping​(Function> mapper,Collector downstream)通过在累积之前对每个输入元素应用Function映射函数,将一个接受U类型元素的收集器调整为一个接受T类型元素。  
static
Collector>>
groupingBy​(Function classifier)

Returns a Collector implementing a "group by" operation on input elements of type T, grouping elements according to a classification function, and returning the results in a Map.

static >
Collector
groupingBy​(Function classifier,Supplier mapFactory, Collector downstream)

Returns a Collector implementing a cascaded "group by" operation on input elements of type T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream Collector.

static
Collector>
groupingBy​(Function classifier, Collector downstream)

Returns a Collector implementing a cascaded "group by" operation on input elements of type T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream Collector.

static
Collector>>
groupingByConcurrent​(Function classifier)

Returns a concurrent Collector implementing a "group by" operation on input elements of type T, grouping elements according to a classification function.

static >
Collector
groupingByConcurrent​(Function classifier,Supplier mapFactory, Collector downstream)

Returns a concurrent Collector implementing a cascaded "group by" operation on input elements of type T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream Collector.

static
Collector>
groupingByConcurrent​(Function classifier,Collector downstream)

Returns a concurrent Collector implementing a cascaded "group by" operation on input elements of type T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream Collector.

staticCollectorjoining()

Returns a Collector that concatenates the input elements into a String, in encounter order.

staticCollectorjoining​(CharSequence delimiter)

Returns a Collector that concatenates the input elements, separated by the specified delimiter, in encounter order.

staticCollectorjoining​(CharSequence delimiter, CharSequence prefix,CharSequence suffix)

Returns a Collector that concatenates the input elements, separated by the specified delimiter, with the specified prefix and suffix, in encounter order.

static
Collector
mapping​(Function mapper, Collector downstream)

Adapts a Collector accepting elements of type U to one accepting elements of type T by applying a mapping function to each input element before accumulation.

static  Collector>maxBy​(Comparator comparator)

Returns a Collector that produces the maximal element according to a given Comparator, described as an Optional.

static  Collector>minBy​(Comparator comparator)

Returns a Collector that produces the minimal element according to a given Comparator, described as an Optional.

static  Collector>>partitioningBy​(Predicate predicate)

Returns a Collector which partitions the input elements according to a Predicate, and organizes them into a Map>.

static
Collector>
partitioningBy​(Predicate predicate, Collector downstream)

Returns a Collector which partitions the input elements according to a Predicate, reduces the values in each partition according to another Collector, and organizes them into a Map whose values are the result of the downstream reduction.

static  Collector>reducing​(BinaryOperator op)

Returns a Collector which performs a reduction of its input elements under a specified BinaryOperator.

static  Collectorreducing​(T identity, BinaryOperator op)

Returns a Collector which performs a reduction of its input elements under a specified BinaryOperator using the provided identity.

static
Collector
reducing​(U identity, Function mapper,BinaryOperator op)

Returns a Collector which performs a reduction of its input elements under a specified mapping function and BinaryOperator.

static  CollectorsummarizingDouble​(ToDoubleFunction mapper)

Returns a Collector which applies an double-producing mapping function to each input element, and returns summary statistics for the resulting values.

static  CollectorsummarizingInt​(ToIntFunction mapper)

Returns a Collector which applies an int-producing mapping function to each input element, and returns summary statistics for the resulting values.

static  CollectorsummarizingLong​(ToLongFunction mapper)

Returns a Collector which applies an long-producing mapping function to each input element, and returns summary statistics for the resulting values.

static  CollectorsummingDouble​(ToDoubleFunction mapper)

Returns a Collector that produces the sum of a double-valued function applied to the input elements.

static  CollectorsummingInt​(ToIntFunction mapper)

Returns a Collector that produces the sum of a integer-valued function applied to the input elements.

static  CollectorsummingLong​(ToLongFunction mapper)

Returns a Collector that produces the sum of a long-valued function applied to the input elements.

static >
Collector
toCollection​(Supplier collectionFactory)

Returns a Collector that accumulates the input elements into a new Collection, in encounter order.

static
Collector>
toConcurrentMap​(Function keyMapper, Function valueMapper)

Returns a concurrent Collector that accumulates elements into a ConcurrentMap whose keys and values are the result of applying the provided mapping functions to the input elements.

static
Collector>
toConcurrentMap​(Function keyMapper, Function valueMapper, BinaryOperator mergeFunction)

Returns a concurrent Collector that accumulates elements into a ConcurrentMap whose keys and values are the result of applying the provided mapping functions to the input elements.

static >
Collector
toConcurrentMap​(Function keyMapper, Function valueMapper, BinaryOperator mergeFunction,Supplier mapFactory)

Returns a concurrent Collector that accumulates elements into a ConcurrentMap whose keys and values are the result of applying the provided mapping functions to the input elements.

static  Collector>toList()

Returns a Collector that accumulates the input elements into a new List.

static
Collector>
toMap​(Function keyMapper, Function valueMapper)

Returns a Collector that accumulates elements into a Map whose keys and values are the result of applying the provided mapping functions to the input elements.

static
Collector>
toMap​(Function keyMapper, Function valueMapper, BinaryOperator mergeFunction)

Returns a Collector that accumulates elements into a Map whose keys and values are the result of applying the provided mapping functions to the input elements.

static >
Collector
toMap​(Function keyMapper, Function valueMapper, BinaryOperator mergeFunction,Supplier mapFactory)

Returns a Collector that accumulates elements into a Map whose keys and values are the result of applying the provided mapping functions to the input elements.

static  Collector>toSet()

Returns a Collector that accumulates the input elements into a new Set.

static  Collector>toUnmodifiableList()

Returns a Collector that accumulates the input elements into an unmodifiable List in encounter order.

static
Collector>
toUnmodifiableMap​(Function keyMapper, Function valueMapper)

Returns a Collector that accumulates the input elements into an unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements.

static
Collector>
toUnmodifiableMap​(Function keyMapper, Function valueMapper, BinaryOperator mergeFunction)

Returns a Collector that accumulates the input elements into an unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements.

static  Collector>toUnmodifiableSet()

Returns a Collector that accumulates the input elements into an unmodifiable Set.

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/764157.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号