JAVA 编程技巧
Steam 编程
Map<String, List<Data>> collect = lists.stream().filter(n ->
StringUtils.isNotEmpty(n.getDepartment())
).collect(Collectors.groupingBy(Data::getDepartment));
Set<String> set = new HashSet<>();
collect.keySet().forEach(n -> {
String[] split = n.split(",");
if(split.length>1){
Stream<String> stream = Arrays.stream(split);
stream.forEach(m->{
set.add(m);
});
}else {
set.add(n);
}
})
set.forEach(n-> System.out.println(n));