publicclassTreeNode{privateint x;privateint y;private Tree tree;publicTreeNode(int x,int y, Tree tree){this.x = x;this.y = y;this.tree = tree;}publicintgetX(){return x;}publicvoidsetX(int x){this.x = x;}publicintgetY(){return y;}publicvoidsetY(int y){this.y = y;}public Tree getTree(){return tree;}publicvoidsetTree(Tree tree){this.tree = tree;}}
树工厂
publicclassTreeFactory{privatestatic Map<String,Tree> map =newConcurrentHashMap<>();publicstatic Tree getTree(String name,String date){if(map.containsKey(name)){return map.get(name);}
Tree tree =newTree(name,date);
map.put(name,tree);return tree;}}