src/main/java/com/genersoft/iot/vmp/utils/node/BaseNode.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/genersoft/iot/vmp/utils/node/ForestNode.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/genersoft/iot/vmp/utils/node/ForestNodeManager.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/genersoft/iot/vmp/utils/node/ForestNodeMerger.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/genersoft/iot/vmp/utils/node/INode.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/genersoft/iot/vmp/utils/node/BaseNode.java
@@ -16,7 +16,7 @@ /** * 主键ID */ protected int id; protected String channelId; /** * 父节点ID @@ -50,21 +50,13 @@ } @Override public int getId() { return id; } public void setId(int id) { this.id = id; public String getChannelId() { return channelId; } @Override public String getParentId() { return parentId; } public void setParentId(String parentId) { this.parentId = parentId; } @Override src/main/java/com/genersoft/iot/vmp/utils/node/ForestNode.java
@@ -15,8 +15,8 @@ */ private Object content; public ForestNode(int id, String parentId, Object content) { this.id = id; public ForestNode(String id, String parentId, Object content) { this.channelId = id; this.parentId = parentId; this.content = content; } src/main/java/com/genersoft/iot/vmp/utils/node/ForestNodeManager.java
@@ -17,15 +17,15 @@ /** * 森林的所有节点 */ private final ImmutableMap<Integer, T> nodeMap; private final ImmutableMap<String, T> nodeMap; /** * 森林的父节点ID */ private final Map<Integer, Object> parentIdMap = Maps.newHashMap(); private final Map<String, Object> parentIdMap = Maps.newHashMap(); public ForestNodeManager(List<T> nodes) { nodeMap = Maps.uniqueIndex(nodes, INode::getId); nodeMap = Maps.uniqueIndex(nodes, INode::getChannelId); } /** @@ -46,7 +46,7 @@ * * @param parentId 父节点ID */ public void addParentId(int parentId) { public void addParentId(String parentId) { parentIdMap.put(parentId, ""); } @@ -58,7 +58,7 @@ public List<T> getRoot() { List<T> roots = new ArrayList<>(); nodeMap.forEach((key, node) -> { if (node.getParentId() == null || parentIdMap.containsKey(node.getId())) { if (node.getParentId() == null || parentIdMap.containsKey(node.getChannelId())) { roots.add(node); } }); src/main/java/com/genersoft/iot/vmp/utils/node/ForestNodeMerger.java
@@ -25,7 +25,7 @@ if (node != null) { node.getChildren().add(forestNode); } else { forestNodeManager.addParentId(forestNode.getId()); forestNodeManager.addParentId(forestNode.getChannelId()); } } }); @@ -37,8 +37,8 @@ items.forEach(forestNode -> { if (forestNode.getParentId() != null) { INode<T> node = forestNodeManager.getTreeNodeAt(forestNode.getParentId()); if (CollectionUtil.contains(parentIds, forestNode.getId())){ forestNodeManager.addParentId(forestNode.getId()); if (CollectionUtil.contains(parentIds, forestNode.getChannelId())){ forestNodeManager.addParentId(forestNode.getChannelId()); } else { if (node != null){ node.getChildren().add(forestNode); src/main/java/com/genersoft/iot/vmp/utils/node/INode.java
@@ -14,7 +14,7 @@ * * @return String */ int getId(); String getChannelId(); /** * 父主键