1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
Map<String, List<Resource1>> map = list .stream().collect(Collectors.groupingBy(Resource1 ::getParent ));
list.forEach(resource -> resource.setChildren(map.get(resource.getId())));
list = list.stream().filter(v-> v.getParent().equals("0") || v.getParent().equals("")).collect(Collectors.toList());
|