private List<CatalogNode> buildChildrenList(List<CatalogNode> catalogList) {
List<CatalogNode> nodeList = catalogList.stream().filter(catalogNode -> StringUtils.isBlank(catalogNode.getPid()))
.map(catalogNode -> {
catalogNode.setChildren(getChildren(catalogNode, catalogList));
return catalogNode;
})
.collect(Collectors.toList());
return nodeList;
}
private List<CatalogNode> getChildren(CatalogNode root, List<CatalogNode> all) {
List<CatalogNode> children = all.stream().filter(catalogNode -> {
if(StringUtils.isNotBlank(catalogNode.getPid())) {
catalogNode.setAttributes(new Attribute("seq", catalogNode.getCatalogSeq()));
return catalogNode.getPid().equals(root.getId());
}
return false;
}
).map((menu) -> {
menu.setChildren(getChildren(menu, all));
return menu;
}).collect(Collectors.toList());
return children;
}