Ztree工具类重名

This commit is contained in:
solo-hx 2019-09-05 15:33:30 +08:00
parent b618aac0d2
commit c441961682
2 changed files with 15 additions and 15 deletions

View File

@ -13,14 +13,14 @@ import java.util.Map;
* @author solo
* @date 2019/09/05.
*/
public class Ztree extends BaseBean {
public class Ztree2 extends BaseBean {
private String id;
private String text;
private String state;
private boolean isParent;
private boolean checked;;
private int locked;
private List<Ztree> children;
private List<Ztree2> children;
private String iconCls;
private String pid;
private Map<String, Object> attributes = new HashMap<String, Object>();
@ -86,11 +86,11 @@ public class Ztree extends BaseBean {
this.locked = locked;
}
public List<Ztree> getChildren() {
public List<Ztree2> getChildren() {
return children;
}
public void setChildren(List<Ztree> children) {
public void setChildren(List<Ztree2> children) {
this.children = children;
}

View File

@ -14,9 +14,9 @@ import java.util.List;
*/
public class ZtreeUtil {
public static List<Ztree> ztreeList(List<Ztree> list,String pid) {
List<Ztree> returnList = new ArrayList<Ztree>();
for (Ztree t : list) {
public static List<Ztree2> ztreeList(List<Ztree2> list, String pid) {
List<Ztree2> returnList = new ArrayList<Ztree2>();
for (Ztree2 t : list) {
if (StringUtils.equals(t.getPid(), pid)) {
recursionFn(list, t);
returnList.add(t);
@ -25,16 +25,16 @@ public class ZtreeUtil {
return returnList;
}
private static void recursionFn(List<Ztree> list, Ztree t) {
List<Ztree> childList = getChildList(list, t);// 得到子节点列表
private static void recursionFn(List<Ztree2> list, Ztree2 t) {
List<Ztree2> childList = getChildList(list, t);// 得到子节点列表
t.setChildren(childList);
t.setState("open");
t.setIsParent(false);
for (Ztree tChild : childList) {
for (Ztree2 tChild : childList) {
t.setState("closed");
t.setIsParent(true);
if (hasChild(list, tChild)) {// 判断是否有子节点
for (Ztree n : childList) {
for (Ztree2 n : childList) {
recursionFn(list, n);
}
}
@ -43,9 +43,9 @@ public class ZtreeUtil {
// 得到子节点列表
private static List<Ztree> getChildList(List<Ztree> list, Ztree t) {
List<Ztree> tlist = new ArrayList<Ztree>();
for (Ztree n : list) {
private static List<Ztree2> getChildList(List<Ztree2> list, Ztree2 t) {
List<Ztree2> tlist = new ArrayList<Ztree2>();
for (Ztree2 n : list) {
if (StringUtils.equals(n.getPid(), t.getId())) {
tlist.add(n);
}
@ -54,7 +54,7 @@ public class ZtreeUtil {
}
// 判断是否有子节点
private static boolean hasChild(List<Ztree> list, Ztree t) {
private static boolean hasChild(List<Ztree2> list, Ztree2 t) {
return getChildList(list, t).size() > 0;
}
}