先取出属性集合,再利用Set去重
List<String> productKeys = dtoList.stream().map(HealthSceneDeviceDto::getProductKey).collect(
Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(k -> k))), ArrayList::new)
);
先取出属性集合,再利用Set去重
List<String> productKeys = dtoList.stream().map(HealthSceneDeviceDto::getProductKey).collect(
Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(k -> k))), ArrayList::new)
);