1.集合内部条件去重 collectingAndThen
操作对象
//操作对象
@Data
public class DataQualityResponseDTO {
/**
* 代码
*/
private String fundCode;
/**
*
*/
private String fundName;
}
//具体使用 依照fundName进行数据去重
List<DataQualityResponseDTO> collect = fileValue.stream()
.collect(Collectors.collectingAndThen(
Collectors.toCollection(
() -> new TreeSet<>(Comparator.comparing(DataQualityResponseDTO ::getName))
), ArrayList::new));