public void setChildren(CrossInfoExt crossTree, List<CrossInfoExt> lists){ List<CrossInfoExt> lists1 = new ArrayList<>(); for(CrossInfoExt crossInfoExt : lists){ if(crossTree.getId() == crossInfoExt.getParentId()){ if(crossInfoExt.getIsLeaf() == 0){ setChildren(crossInfoExt,lists); } lists1.add(crossInfoExt); } } crossTree.setChildren(lists1);
}
import java.util.List; /** * 卡口扩展类 * @author yuyanwu * @date 2018-4-27 */ public class CrossInfoExt { private int id; private String indexCode; private String name; private String type; private int parentId; private String icon; private boolean open; private boolean checked; private int isLeaf; private boolean isParent; private List<CrossInfoExt> children; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getIndexCode() { return indexCode; } public void setIndexCode(String indexCode) { this.indexCode = indexCode; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getType() { return type; } public void setType(String type) { this.type = type; } public int getParentId() { return parentId; } public void setParentId(int parentId) { this.parentId = parentId; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public boolean isOpen() { return open; } public void setOpen(boolean open) { this.open = open; } public boolean isChecked() { return checked; } public void setChecked(boolean checked) { this.checked = checked; } public int getIsLeaf() { return isLeaf; } public void setIsLeaf(int isLeaf) { this.isLeaf = isLeaf; } public boolean isParent() { return isParent; } public void setParent(boolean parent) { isParent = parent; } public List<CrossInfoExt> getChildren() { return children; } public void setChildren(List<CrossInfoExt> children) { this.children = children; } }