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;
}
posted @ 2021-07-15 10:11  scwyfy  阅读(323)  评论(0编辑  收藏  举报