use of com.alibaba.csp.sentinel.command.vo.NodeVo in project RuoYi-Cloud-Plus by JavaLionLi.
the class ResourceTreeNode method fromNodeVoList.
public static ResourceTreeNode fromNodeVoList(List<NodeVo> nodeVos) {
if (nodeVos == null || nodeVos.isEmpty()) {
return null;
}
ResourceTreeNode root = null;
Map<String, ResourceTreeNode> map = new HashMap<>();
for (NodeVo vo : nodeVos) {
ResourceTreeNode node = fromNodeVo(vo);
map.put(node.id, node);
// real root
if (node.parentId == null || node.parentId.isEmpty()) {
root = node;
} else if (map.containsKey(node.parentId)) {
map.get(node.parentId).children.add(node);
} else {
// impossible
}
}
return root;
}
Aggregations