1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.resolution;
20
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.Collections;
24 import java.util.List;
25 import java.util.Map;
26
27 import org.eclipse.aether.RepositorySystem;
28 import org.eclipse.aether.artifact.Artifact;
29 import org.eclipse.aether.graph.Dependency;
30 import org.eclipse.aether.repository.ArtifactRepository;
31 import org.eclipse.aether.repository.RemoteRepository;
32
33 import static java.util.Objects.requireNonNull;
34
35
36
37
38
39
40 public final class ArtifactDescriptorResult {
41
42 private final ArtifactDescriptorRequest request;
43
44 private List<Exception> exceptions;
45
46 private List<Artifact> relocations;
47
48 private Collection<Artifact> aliases;
49
50 private Artifact artifact;
51
52 private ArtifactRepository repository;
53
54 private List<Dependency> dependencies;
55
56 private List<Dependency> managedDependencies;
57
58 private List<RemoteRepository> repositories;
59
60 private Map<String, Object> properties;
61
62
63
64
65
66
67 public ArtifactDescriptorResult(ArtifactDescriptorRequest request) {
68 this.request = requireNonNull(request, "artifact descriptor request cannot be null");
69 artifact = request.getArtifact();
70 exceptions = Collections.emptyList();
71 relocations = Collections.emptyList();
72 aliases = Collections.emptyList();
73 dependencies = Collections.emptyList();
74 managedDependencies = Collections.emptyList();
75 repositories = Collections.emptyList();
76 properties = Collections.emptyMap();
77 }
78
79
80
81
82
83
84 public ArtifactDescriptorRequest getRequest() {
85 return request;
86 }
87
88
89
90
91
92
93 public List<Exception> getExceptions() {
94 return exceptions;
95 }
96
97
98
99
100
101
102
103 public ArtifactDescriptorResult setExceptions(List<Exception> exceptions) {
104 if (exceptions == null) {
105 this.exceptions = Collections.emptyList();
106 } else {
107 this.exceptions = exceptions;
108 }
109 return this;
110 }
111
112
113
114
115
116
117
118 public ArtifactDescriptorResult addException(Exception exception) {
119 if (exception != null) {
120 if (exceptions.isEmpty()) {
121 exceptions = new ArrayList<>();
122 }
123 exceptions.add(exception);
124 }
125 return this;
126 }
127
128
129
130
131
132
133
134 public List<Artifact> getRelocations() {
135 return relocations;
136 }
137
138
139
140
141
142
143
144 public ArtifactDescriptorResult setRelocations(List<Artifact> relocations) {
145 if (relocations == null) {
146 this.relocations = Collections.emptyList();
147 } else {
148 this.relocations = relocations;
149 }
150 return this;
151 }
152
153
154
155
156
157
158
159 public ArtifactDescriptorResult addRelocation(Artifact artifact) {
160 if (artifact != null) {
161 if (relocations.isEmpty()) {
162 relocations = new ArrayList<>();
163 }
164 relocations.add(artifact);
165 }
166 return this;
167 }
168
169
170
171
172
173
174
175
176 public Collection<Artifact> getAliases() {
177 return aliases;
178 }
179
180
181
182
183
184
185
186 public ArtifactDescriptorResult setAliases(Collection<Artifact> aliases) {
187 if (aliases == null) {
188 this.aliases = Collections.emptyList();
189 } else {
190 this.aliases = aliases;
191 }
192 return this;
193 }
194
195
196
197
198
199
200
201 public ArtifactDescriptorResult addAlias(Artifact alias) {
202 if (alias != null) {
203 if (aliases.isEmpty()) {
204 aliases = new ArrayList<>();
205 }
206 aliases.add(alias);
207 }
208 return this;
209 }
210
211
212
213
214
215
216
217 public Artifact getArtifact() {
218 return artifact;
219 }
220
221
222
223
224
225
226
227 public ArtifactDescriptorResult setArtifact(Artifact artifact) {
228 this.artifact = artifact;
229 return this;
230 }
231
232
233
234
235
236
237 public ArtifactRepository getRepository() {
238 return repository;
239 }
240
241
242
243
244
245
246
247 public ArtifactDescriptorResult setRepository(ArtifactRepository repository) {
248 this.repository = repository;
249 return this;
250 }
251
252
253
254
255
256
257 public List<Dependency> getDependencies() {
258 return dependencies;
259 }
260
261
262
263
264
265
266
267 public ArtifactDescriptorResult setDependencies(List<Dependency> dependencies) {
268 if (dependencies == null) {
269 this.dependencies = Collections.emptyList();
270 } else {
271 this.dependencies = dependencies;
272 }
273 return this;
274 }
275
276
277
278
279
280
281
282 public ArtifactDescriptorResult addDependency(Dependency dependency) {
283 if (dependency != null) {
284 if (dependencies.isEmpty()) {
285 dependencies = new ArrayList<>();
286 }
287 dependencies.add(dependency);
288 }
289 return this;
290 }
291
292
293
294
295
296
297 public List<Dependency> getManagedDependencies() {
298 return managedDependencies;
299 }
300
301
302
303
304
305
306
307 public ArtifactDescriptorResult setManagedDependencies(List<Dependency> dependencies) {
308 if (dependencies == null) {
309 this.managedDependencies = Collections.emptyList();
310 } else {
311 this.managedDependencies = dependencies;
312 }
313 return this;
314 }
315
316
317
318
319
320
321
322 public ArtifactDescriptorResult addManagedDependency(Dependency dependency) {
323 if (dependency != null) {
324 if (managedDependencies.isEmpty()) {
325 managedDependencies = new ArrayList<>();
326 }
327 managedDependencies.add(dependency);
328 }
329 return this;
330 }
331
332
333
334
335
336
337 public List<RemoteRepository> getRepositories() {
338 return repositories;
339 }
340
341
342
343
344
345
346
347 public ArtifactDescriptorResult setRepositories(List<RemoteRepository> repositories) {
348 if (repositories == null) {
349 this.repositories = Collections.emptyList();
350 } else {
351 this.repositories = repositories;
352 }
353 return this;
354 }
355
356
357
358
359
360
361
362 public ArtifactDescriptorResult addRepository(RemoteRepository repository) {
363 if (repository != null) {
364 if (repositories.isEmpty()) {
365 repositories = new ArrayList<>();
366 }
367 repositories.add(repository);
368 }
369 return this;
370 }
371
372
373
374
375
376
377
378 public Map<String, Object> getProperties() {
379 return properties;
380 }
381
382
383
384
385
386
387
388 public ArtifactDescriptorResult setProperties(Map<String, Object> properties) {
389 if (properties == null) {
390 this.properties = Collections.emptyMap();
391 } else {
392 this.properties = properties;
393 }
394 return this;
395 }
396
397 @Override
398 public String toString() {
399 return getArtifact() + " -> " + getDependencies();
400 }
401 }