cn.woodwhales.common.example.business.tree.TreeToolExample Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of woodwhales-common Show documentation
Show all versions of woodwhales-common Show documentation
https://github.com/woodwhales
package cn.woodwhales.common.example.business.tree;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import cn.woodwhales.common.business.tree.TreeNode;
import cn.woodwhales.common.business.tree.TreeNodeAttributeMapper;
import cn.woodwhales.common.business.tree.TreeTool;
import cn.woodwhales.common.example.model.business.tree.MyTreeNodeGenerator;
import cn.woodwhales.common.example.model.business.tree.TreeToolTempMenu;
import java.util.List;
import java.util.Map;
/**
* @author woodwhales on 2021-07-25 12:25
* TreeTool 使用示例
*/
public class TreeToolExample {
private static List testList;
public static void init() {
List list = Lists.newArrayListWithCapacity(6);
list.add(new TreeToolTempMenu(9, null, "上海", 30));
list.add(new TreeToolTempMenu(1, null, "北京", 10));
list.add(new TreeToolTempMenu(2, 1, "海淀", 1));
list.add(new TreeToolTempMenu(4, 1, "西城", 3));
list.add(new TreeToolTempMenu(3, 1, "朝阳", 2));
list.add(new TreeToolTempMenu(9, 1, "东城", 0));
list.add(new TreeToolTempMenu(5, null, "安徽", 20));
list.add(new TreeToolTempMenu(6, 5, "合肥", 1));
list.add(new TreeToolTempMenu(7, 5, "安庆", 2));
list.add(new TreeToolTempMenu(8, 5, "黄山", 3));
testList = list;
}
public static void main(String[] args) {
test1();
test2();
test3();
test4();
test5();
}
public static void test1() {
init();
List> tree1 = TreeTool.tree(TreeToolExample.testList, new MyTreeNodeGenerator());
print(tree1);
}
public static void test2() {
init();
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy