1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.index.treeview;
20
21 import java.io.IOException;
22 import java.util.ArrayList;
23 import java.util.List;
24
25
26
27
28 public abstract class AbstractTreeNode implements TreeNode {
29
30
31
32 private String type;
33
34
35
36
37 private boolean leaf;
38
39
40
41
42 private String nodeName;
43
44
45
46
47 private String path;
48
49
50
51
52 private List<TreeNode> children;
53
54
55
56
57 private String groupId;
58
59
60
61
62 private String artifactId;
63
64
65
66
67 private String version;
68
69
70
71
72 private String repositoryId;
73
74 private final transient IndexTreeView treeView;
75
76 private final transient TreeViewRequest request;
77
78
79
80
81
82
83
84 public AbstractTreeNode(IndexTreeView tview, TreeViewRequest request) {
85 this.treeView = tview;
86
87 this.request = request;
88 }
89
90
91
92
93
94
95 public Type getType() {
96 return Type.valueOf(type);
97 }
98
99
100
101
102
103
104 public void setType(Type type) {
105 this.type = type.name();
106 }
107
108
109
110
111
112
113 public boolean isLeaf() {
114 return leaf;
115 }
116
117
118
119
120
121
122 public void setLeaf(boolean leaf) {
123 this.leaf = leaf;
124 }
125
126
127
128
129
130
131 public String getNodeName() {
132 return nodeName;
133 }
134
135
136
137
138
139
140 public void setNodeName(String nodeName) {
141 this.nodeName = nodeName;
142 }
143
144
145
146
147
148
149 public String getPath() {
150 return path;
151 }
152
153
154
155
156
157
158 public void setPath(String path) {
159 this.path = path;
160 }
161
162
163
164
165
166
167 public String getGroupId() {
168 return groupId;
169 }
170
171
172
173
174
175
176 public void setGroupId(String groupId) {
177 this.groupId = groupId;
178 }
179
180
181
182
183
184
185 public String getArtifactId() {
186 return artifactId;
187 }
188
189
190
191
192
193
194 public void setArtifactId(String artifactId) {
195 this.artifactId = artifactId;
196 }
197
198
199
200
201
202
203 public String getVersion() {
204 return version;
205 }
206
207
208
209
210
211
212 public void setVersion(String version) {
213 this.version = version;
214 }
215
216
217
218
219
220
221 public String getRepositoryId() {
222 return repositoryId;
223 }
224
225
226
227
228
229
230 public void setRepositoryId(String repositoryId) {
231 this.repositoryId = repositoryId;
232 }
233
234
235
236
237
238
239
240
241 public List<TreeNode> getChildren() {
242 if (children == null && !isLeaf()) {
243 children = new ArrayList<>();
244 }
245
246 return children;
247 }
248
249
250
251
252
253
254
255 public List<TreeNode> listChildren() throws IOException {
256 if (!isLeaf() && getChildren().isEmpty() && !isLeaf()) {
257 children = treeView.listNodes(new TreeViewRequest(
258 request.getFactory(),
259 getPath(),
260 request.getFieldHints(),
261 request.getArtifactInfoFilter(),
262 request.getIndexingContext()))
263 .getChildren();
264 }
265
266 return children;
267 }
268
269
270
271
272
273
274 public TreeNode findChildByPath(String path, Type type) throws IOException {
275 for (TreeNode child : getChildren()) {
276 if (path.equals(child.getPath()) && type.equals(child.getType())) {
277 return child;
278 }
279 }
280
281 return null;
282 }
283 }