原文鏈接: https://www.cnblogs.com/coding88/p/12748945.html
本來是一個菜單集合,然后按父節點分組,將子節點全部合並到一個list中
|
1
2
3
4
5
6
7
|
List<SysMenu> menuList =
new
ArrayList<>();
Map<String, List<SysMenu>> menuMap = menutList.stream().collect(Collectors.toMap(SysMenu::getParentId, menuObj ->
Lists.newArrayList(menuObj), (List<SysMenu> newValueList, List<SysMenu> oldValueList) ->
{
oldValueList.addAll(newValueList);
return
oldValueList;
}));
|
