介绍
java.util.stream.Collectors
public final class Collectors
API
static
生成集合
- toCollection
- toList
- toUnmodifiableList
- toSet
- toUnmodifiableSet
生成 Map
- toMap
- toUnmodifiableMap
- toConcurrentMap
生成字符串
- joining
Collector<CharSequence, ?, String> joining()
Collector<CharSequence, ?, String> joining(CharSequence delimiter)
Collector<CharSequence, ?, String> joining(CharSequence delimiter, CharSequence prefix, CharSequence suffix)
生成 (Int|Long|Double)SummaryStatistics
汇总对象
- summingInt
- summingLong
- summingDouble
平均值
- averagingInt
- averagingLong
- averagingDouble
约简
- reducing
<T> Collector<T, ?, Optional<T>> reducing(BinaryOperator<T> op)
<T> Collector<T, ?, T> reducing(T identity, BinaryOperator<T> op)
- identity 幺元
- counting
- minBy
- maxBy
群组
- groupingBy
- groupingByConcurrent
分区
- partitioningBy
- 产生 Map ,键是
Boolean
,值是 List<T>
统计
- summarizingInt
- summarizingLong
- summarizingDouble
再处理
- collectingAndThen
<T,A,R,RR> Collector<T,A,RR> collectingAndThen(Collector<T,A,R> downstream, Function<R,RR> finisher)
- 在收集器后面添加了一个最终处理步骤
- mapping
<T, U, A, R> Collector<T, ?, R> mapping(Function<? super T, ? extends U> mapper, Collector<? super U, A, R> downstream)
- 反
collectingAndThen
- 将收集到的元素传给下游处理器
- filtering
- flatMapping
- teeing
<T, R1, R2, R> Collector<T, ?, R> teeing(Collector<? super T, ?, R1> downstream1, Collector<? super T, ?, R2> downstream2, BiFunction<? super R1, ? super R2, R> merger)
- 将两个收集器结果合并为一个
posted @
2023-08-22 17:38
流星<。)#)))≦
阅读(
28)
评论()
编辑
收藏
举报