当前位置:网站首页>树形结构构造示例代码
树形结构构造示例代码
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;
}边栏推荐
- Adobe官方清理工具Adobe Creative Cloud Cleaner Tool使用教程
- 封装和包、访问修饰权限
- 用户之声 | 大学生的“课外学堂”
- golang source code analysis: uber-go/ratelimit
- iframe------------frame-
- Digital twins help visualize the construction of smart cities
- 李沐动手学深度学习V2-BERT预训练和代码实现
- 9,共模抑制比一-不受输入信号中共模波动的影响。【如何分析共模CM抑制比。】
- HCIP--路由策略实验
- php 单引号 双引号 -> => return echo
猜你喜欢
随机推荐
[21 Days Learning Challenge] Bubble Sort and Insertion Sort
Day12 接口和协议
汉源高科千兆4光4电工业级网管型智能环网冗余以太网交换机防浪涌防雷导轨式安装
arm64麒麟安装paddlehub(国产化)
用户之声 | 我与GBase的缘分
基本语法(三)
go——垃圾回收机制(GC)
典型相关分析CCA计算过程
PLC工作原理动画
ACE JET NPOI
传感器工作原理
广东省数字经济发展指引 1.0之建成数据安全保障体系
【SLAM】DM-VIO(ros版)安装和论文解读
浅议.NET遗留应用改造
.NET performance optimization - you should set initial size for collection types
信息学奥赛一本通(1258:【例9.2】数字金字塔)
Electrical diagram of power supply system
The five classification of software testing
Nervegrowold hands-on learning deep learning V2 - Bert pre training data set and code implementation
vscode如何能将输出从OUTPUT改为TERMINAL或者DebugConsole









