首页 > TAG信息列表 > collectingAndThen
如何根据对象的属性去重?JDK 8 Stream 轻松搞定(来长长见识)
作者:goodluckwj 来源:blog.csdn.net/qq_35634181/article/details/108867857 ExportTemperatureDto实体对象: @Getter @Setter @ToString public class ExportTemperatureDto { private String name; private Double morningTemperature; private Double afternoonTempeJava stream操作collectingAndThen根据对象的属性去重
创建实体对象user /** * 用户 * * @author sun * @date 2021/08/19 */ @Data public class User { private Integer id; private String name; private String password; private Integer age; private String address; public User()Collectors.collectingAndThen()
Collectors.collectingAndThen() Java 8 流的新类 java.util.stream.Collectors 实现了 java.util.stream.Collector 接口,同时又提供了大量的方法对流 ( stream ) 的元素执行 map and reduce 操作,或者统计操作。 Collectors.collectingAndThen() 函数应该最像 map and reduJava 8 Collectors.collectingAndThen()
java.util.stream.Collectors#collectingAndThen方法的作用是将Collector的结果在执行一个额外的finisher转换操作,其源码如下: /** * Adapts a {@code Collector} to perform an additional finishing * transformation. For example, one could adapt the {@link #toList()} * c