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