io.github.jinghui70.rainbow.utils.tree.TreeNode Maven / Gradle / Ivy
The newest version!
package io.github.jinghui70.rainbow.utils.tree;
import cn.hutool.core.collection.CollUtil;
import io.github.jinghui70.rainbow.dbaccess.annotation.Transient;
import java.util.ArrayList;
import java.util.List;
public class TreeNode> implements ITreeNode {
@Transient
private List children;
@Override
public List getChildren() {
return children;
}
public void setChildren(List children) {
this.children = children;
}
public void addChild(T child) {
if (children == null) {
children = new ArrayList<>();
}
children.add(child);
}
public void addChildren(List children) {
if (this.children == null) {
this.children = new ArrayList<>();
}
this.children.addAll(children);
}
public boolean hasChild() {
return CollUtil.isNotEmpty(children);
}
}