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