shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package com.walker.infrastructure.tree;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * ID采用字符串形式。
 * @author 时克英
 * @date 2023-07-13
 */
public class TreeNodeString implements Comparable<TreeNodeString> {
 
    private String id;
    private String label;
    private String parentId;
    private List<TreeNodeString> children = null;
    private Object source = null;
 
    public String getCode() {
        return code;
    }
 
    public void setCode(String code) {
        this.code = code;
    }
 
    private String code;
 
    public TreeNodeString(String id, String label, List<TreeNodeString> children, String parentId){
        this.id = id;
        this.label = label;
        this.children = children;
        this.parentId = parentId;
    }
    public TreeNodeString(String id, String label, List<TreeNodeString> children, String parentId, String code){
        this.id = id;
        this.label = label;
        this.children = children;
        this.parentId = parentId;
        this.code = code;
    }
 
    public void addChild(TreeNodeString node) {
        if(node != null){
            if(children == null){
                this.children = new ArrayList<>(8);
            }
            if(!this.children.contains(node)){
                this.children.add(node);
            }
        }
    }
 
    public Object getSource() {
        return source;
    }
 
    public void setSource(Object source) {
        this.source = source;
    }
 
    public String getId() {
        return id;
    }
 
    public void setId(String id) {
        this.id = id;
    }
 
    public String getLabel() {
        return label;
    }
 
    public void setLabel(String label) {
        this.label = label;
    }
 
    public String getParentId() {
        return parentId;
    }
 
    public void setParentId(String parentId) {
        this.parentId = parentId;
    }
 
    public List<TreeNodeString> getChildren() {
        return children;
    }
 
    public void setChildren(List<TreeNodeString> children) {
        this.children = children;
    }
 
    public void cloneProperties(TreeNodeString node) {
        this.id = node.getId();
        this.label = node.getLabel();
        this.source = node.getSource();
//        this.order = node.getOrder();
    }
 
    @Override
    public int hashCode(){
        return this.id.hashCode();
    }
 
    @Override
    public boolean equals(Object obj){
        if(obj == null){
            return false;
        }
        if(obj instanceof TreeNodeString){
            TreeNodeString treeNode = (TreeNodeString) obj;
            if(treeNode.id == this.id){
                return true;
            }
        }
        return false;
    }
 
    @Override
    public String toString(){
        return new StringBuilder("[id=").append(this.id)
                .append(", label=").append(this.label)
                .append(", children=").append(this.children)
                .append(", parentId=").append(this.parentId)
                .append("]").toString();
    }
 
    @Override
    public int compareTo(TreeNodeString o) {
        return 0;
    }
}