package com.thunisoft.datavisualization.common.util;
import com.thunisoft.datavisualization.common.model.Node;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
public final class ParentAndChildUtils {
static List<String> chlidrenCropList=new ArrayList<>();
static List<String> parentCropList=new ArrayList<>();
public static List<String> getChildrenCropListOutMyself(List<Node> nodes, String pid) {
for (Node crop: nodes) {
if (pid.equals(crop.getPid())) {
getChildrenCropListOutMyself(nodes,crop.getId());
chlidrenCropList.add(crop.getId());
}
}
return chlidrenCropList;
}
/*
* 获取父节点的方法 递归 包含了自己的节点
*
* @param 该节点的id
*/
public static List<String> getParentCropList(List<Node> nodes,String id) {
for (Node crop : nodes) {
if (id!=null&&id.equals(crop.getId())) {
getParentCropList(nodes,crop.getPid());
parentCropList.add(crop.getId());
}
}
return parentCropList;
}
}