jdk8-》List去重

去重集合List<<Map<String, Object>>

public static List<Map<String, Object>> duplicateKey(List<Map<String, Object>> list) {
if (ObjectUtil.isNotEmpty(list)) {
list = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(
() -> new TreeSet<>(Comparator.comparing(itemMap -> itemMap.get("key").toString()))), ArrayList::new));
}
return list;
}
原文地址:https://www.cnblogs.com/yuefeng123/p/15014146.html