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