当前位置:网站首页>树形结构构造示例代码
树形结构构造示例代码
2022-08-02 20:36:00 【jsxztshaohaibo】
/** * 构造树形结构 * @param resourceList * @return */ public List<RResource> buildResourceTreeInfo(List<RResource> resourceList) { List<RResource> result = new ArrayList<>(); Map<String,RResource> record = new HashMap<>(); for (RResource resource : resourceList) { if (RResource.TOP_LEVEL_NODE.equals(resource.getParentId())) {//TOP_LEVEL_NODE=0 resource.setChildren(new ArrayList<>()); result.add(resource); } record.put(resource.getId(), resource); } for (RResource resource : resourceList) { if (StringUtils.isNotBlank(resource.getParentId()) &&!RResource.TOP_LEVEL_NODE.equals(resource.getParentId())) {//TOP_LEVEL_NODE=0 RResource parent = record.get(resource.getParentId()); if (parent != null) { parent.getChildren().add(resource); } } } return result; }
边栏推荐
猜你喜欢
软件成分分析:华为云重磅发布开源软件治理服务
The software testing process specification is what?Specific what to do?
VisualStudio 制作Dynamic Link Library动态链接库文件
2022年金九银十,Android面试中高频必问的问题汇总
ICLR 2022最佳论文:基于对比消歧的偏标签学习
DataGrip 安装教程 详细版
汉源高科千兆4光4电工业级网管型智能环网冗余以太网交换机防浪涌防雷导轨式安装
SublimeText3 安装、配置项、包管理、常用必备插件、常用快捷键以及修改
「每周译Go」这次我们来点不一样的!--《How to Code in Go》系列上线
PyRosetta 安装方法之Conda安装
随机推荐
Day35 LeetCode
基本语法(三)
[C题目]力扣141. 环形链表
EasyExcel dynamic parsing and save table columns
ORB SLAM3加载Vocabulary更快ORBvoc.bin
JMeter的基本使用
千人优学 | GBase 8s数据库2022年6月大学生专场实训圆满结束
Digital twins help visualize the construction of smart cities
arm64麒麟安装paddlehub(国产化)
C语言中变量在内存中的保存与访问
14、学习MySQL 连接的使用
9,共模抑制比一-不受输入信号中共模波动的影响。【如何分析共模CM抑制比。】
Golang source code analysis: time/rate
华为设备配置BFD多跳检测
奥特学园ROS笔记--7(289-325节)
解道7-编程技术4
Qt提升自定义控件,找不到头文件
什么是 IDE
PLC工作原理动画
解道9-编程技术6