关于这个代码存在疑问
来源:2-13 开发RBAC Controller层
weixin_慕设计6199974
2021-12-01 19:45:54
问题描述:
对于这个代码没有理解过来,为什么这样写他就可以变成不是平行的关系呢
相关代码:
List<Map> treeList =new ArrayList<>(); Map module =null; for (Node node:nodes) { if (node.getNodeType() == 1){ module = new LinkedHashMap(); module.put("node",node); module.put("children",new ArrayList<>()); treeList.add(module); }else if (node.getNodeType() ==2){ List children = (List)module.get("children"); children.add(node); } }
1回答
好帮手慕阿园
2021-12-02
同学你好,这段代码是表示,如果获取到的NodeType为1,则说明是模块,如果NodeType为2,则说明是具体的功能,整体表示,如果是模块,则创建对应的模块,如果是具体的功能,则将功能添加到该模块;将功能添加到模块中后就不是平级关系了
祝学习愉快~
相似问题
回答 1
回答 1