优化代码
This commit is contained in:
parent
0e152e2ac7
commit
ae3897ba78
|
@ -16,7 +16,7 @@ public class TreeUtils {
|
||||||
/**
|
/**
|
||||||
* 根据pid,构建树节点
|
* 根据pid,构建树节点
|
||||||
*/
|
*/
|
||||||
public static <T extends TreeNode> List<T> build(List<T> treeNodes, Long pid) {
|
public static <T extends TreeNode<T>> List<T> build(List<T> treeNodes, Long pid) {
|
||||||
// pid不能为空
|
// pid不能为空
|
||||||
AssertUtils.isNull(pid, "pid");
|
AssertUtils.isNull(pid, "pid");
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class TreeUtils {
|
||||||
/**
|
/**
|
||||||
* 查找子节点
|
* 查找子节点
|
||||||
*/
|
*/
|
||||||
private static <T extends TreeNode> T findChildren(List<T> treeNodes, T rootNode) {
|
private static <T extends TreeNode<T>> T findChildren(List<T> treeNodes, T rootNode) {
|
||||||
for (T treeNode : treeNodes) {
|
for (T treeNode : treeNodes) {
|
||||||
if (rootNode.getId().equals(treeNode.getPid())) {
|
if (rootNode.getId().equals(treeNode.getPid())) {
|
||||||
rootNode.getChildren().add(findChildren(treeNodes, treeNode));
|
rootNode.getChildren().add(findChildren(treeNodes, treeNode));
|
||||||
|
@ -45,7 +45,7 @@ public class TreeUtils {
|
||||||
/**
|
/**
|
||||||
* 构建树节点
|
* 构建树节点
|
||||||
*/
|
*/
|
||||||
public static <T extends TreeNode> List<T> build(List<T> treeNodes) {
|
public static <T extends TreeNode<T>> List<T> build(List<T> treeNodes) {
|
||||||
List<T> result = new ArrayList<>();
|
List<T> result = new ArrayList<>();
|
||||||
|
|
||||||
// list转map
|
// list转map
|
||||||
|
|
Loading…
Reference in New Issue
Block a user