直接上代码
//根据name和value去重
List<Label> distinctLabels = allLabels.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getName() + ";" + o.getValue()))
), ArrayList::new));
//根据name和value去重
List<Label> distinctLabels = allLabels.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getName() + ";" + o.getValue()))
), ArrayList::new));