public class TreeNode<T> extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
TreeNode<T> |
addChild(T child) |
void |
addChild(TreeNode<T> child) |
List<TreeNode<T>> |
getChildren() |
T[] |
getPath()
获得从当前节点一直到跟节点路径上所有节点的值
|
int |
getPathCount()
计算节点到根节点之间的层数,包括自己和根节点
|
TreeNode<T> |
getPraent() |
TreeNode<T> |
getRootTreeNode()
获得根节点
|
T |
getRootValue()
获得根节点的值
|
TreeNode<T>[] |
getTreeNodePath()
获得从当前节点一直到跟节点路径上所有节点
|
T |
getValue() |
boolean |
isLeaf() |
boolean |
isRoot()
判断是否为根节点
|
void |
setChildren(List<TreeNode<T>> children) |
void |
setPraent(TreeNode<T> praent) |
void |
setValue(T value) |
static com.alibaba.fastjson2.JSONArray |
toJSONArray(List<? extends TreeNode<?>> forest) |
static com.alibaba.fastjson2.JSONArray |
toJSONArray(List<? extends TreeNode<?>> forest,
String childrenPropertyName) |
com.alibaba.fastjson2.JSONObject |
toJSONObject() |
com.alibaba.fastjson2.JSONObject |
toJSONObject(String childrenPropertyName) |
String |
toString() |
public TreeNode()
public TreeNode(T value)
public T getValue()
public void setValue(T value)
public boolean isLeaf()
public boolean isRoot()
public com.alibaba.fastjson2.JSONObject toJSONObject(String childrenPropertyName)
public static com.alibaba.fastjson2.JSONArray toJSONArray(List<? extends TreeNode<?>> forest, String childrenPropertyName)
public static com.alibaba.fastjson2.JSONArray toJSONArray(List<? extends TreeNode<?>> forest)
public com.alibaba.fastjson2.JSONObject toJSONObject()
public int getPathCount()
public T[] getPath()
public T getRootValue()
Copyright © 2025 江苏南大先腾信息产业股份有限公司. All rights reserved.