1
2
3
4 package org.apache.maven.api.model;
5
6 import java.io.Serializable;
7 import java.util.Collections;
8 import java.util.HashMap;
9 import java.util.Map;
10 import org.apache.maven.api.annotations.Experimental;
11 import org.apache.maven.api.annotations.Generated;
12 import org.apache.maven.api.annotations.Immutable;
13 import org.apache.maven.api.annotations.Nonnull;
14 import org.apache.maven.api.annotations.NotThreadSafe;
15 import org.apache.maven.api.annotations.ThreadSafe;
16
17
18
19
20
21 @Experimental
22 @Generated @ThreadSafe @Immutable
23 public class DistributionManagement
24 implements Serializable, InputLocationTracker
25 {
26
27
28
29
30 final DeploymentRepository repository;
31
32
33
34
35 final DeploymentRepository snapshotRepository;
36
37
38
39 final Site site;
40
41
42
43
44
45
46 final String downloadUrl;
47
48
49
50
51 final Relocation relocation;
52
53
54
55
56
57
58
59
60
61 final String status;
62
63 final InputLocation location;
64
65 final InputLocation repositoryLocation;
66
67 final InputLocation snapshotRepositoryLocation;
68
69 final InputLocation siteLocation;
70
71 final InputLocation downloadUrlLocation;
72
73 final InputLocation relocationLocation;
74
75 final InputLocation statusLocation;
76
77 final Map<Object, InputLocation> locations;
78
79
80
81
82
83 DistributionManagement(
84 DeploymentRepository repository,
85 DeploymentRepository snapshotRepository,
86 Site site,
87 String downloadUrl,
88 Relocation relocation,
89 String status,
90 Map<Object, InputLocation> locations,
91 InputLocation location,
92 InputLocation repositoryLocation,
93 InputLocation snapshotRepositoryLocation,
94 InputLocation siteLocation,
95 InputLocation downloadUrlLocation,
96 InputLocation relocationLocation,
97 InputLocation statusLocation
98 )
99 {
100 this.repository = repository;
101 this.snapshotRepository = snapshotRepository;
102 this.site = site;
103 this.downloadUrl = downloadUrl;
104 this.relocation = relocation;
105 this.status = status;
106 this.locations = ImmutableCollections.copy( locations );
107 this.location = location;
108 this.repositoryLocation = repositoryLocation;
109 this.snapshotRepositoryLocation = snapshotRepositoryLocation;
110 this.siteLocation = siteLocation;
111 this.downloadUrlLocation = downloadUrlLocation;
112 this.relocationLocation = relocationLocation;
113 this.statusLocation = statusLocation;
114 }
115
116
117
118
119
120
121
122 public DeploymentRepository getRepository()
123 {
124 return this.repository;
125 }
126
127
128
129
130
131
132
133 public DeploymentRepository getSnapshotRepository()
134 {
135 return this.snapshotRepository;
136 }
137
138
139
140
141
142
143 public Site getSite()
144 {
145 return this.site;
146 }
147
148
149
150
151
152
153
154
155
156 public String getDownloadUrl()
157 {
158 return this.downloadUrl;
159 }
160
161
162
163
164
165
166
167 public Relocation getRelocation()
168 {
169 return this.relocation;
170 }
171
172
173
174
175
176
177
178
179
180
181
182
183 public String getStatus()
184 {
185 return this.status;
186 }
187
188
189
190
191 public InputLocation getLocation( Object key )
192 {
193 if ( key instanceof String )
194 {
195 switch ( ( String ) key )
196 {
197 case "":
198 return location;
199 case "repository":
200 return repositoryLocation;
201 case "snapshotRepository":
202 return snapshotRepositoryLocation;
203 case "site":
204 return siteLocation;
205 case "downloadUrl":
206 return downloadUrlLocation;
207 case "relocation":
208 return relocationLocation;
209 case "status":
210 return statusLocation;
211 }
212 }
213 return locations != null ? locations.get( key ) : null;
214 }
215
216
217
218
219
220
221 @Nonnull
222 public Builder with()
223 {
224 return newBuilder( this );
225 }
226
227
228
229
230
231
232 @Nonnull
233 public DistributionManagement withRepository( DeploymentRepository repository )
234 {
235 return with().repository( repository ).build();
236 }
237
238
239
240
241
242
243 @Nonnull
244 public DistributionManagement withSnapshotRepository( DeploymentRepository snapshotRepository )
245 {
246 return with().snapshotRepository( snapshotRepository ).build();
247 }
248
249
250
251
252
253
254 @Nonnull
255 public DistributionManagement withSite( Site site )
256 {
257 return with().site( site ).build();
258 }
259
260
261
262
263
264
265 @Nonnull
266 public DistributionManagement withDownloadUrl( String downloadUrl )
267 {
268 return with().downloadUrl( downloadUrl ).build();
269 }
270
271
272
273
274
275
276 @Nonnull
277 public DistributionManagement withRelocation( Relocation relocation )
278 {
279 return with().relocation( relocation ).build();
280 }
281
282
283
284
285
286
287 @Nonnull
288 public DistributionManagement withStatus( String status )
289 {
290 return with().status( status ).build();
291 }
292
293
294
295
296
297
298
299
300 @Nonnull
301 public static DistributionManagement newInstance()
302 {
303 return newInstance( true );
304 }
305
306
307
308
309
310
311
312
313 @Nonnull
314 public static DistributionManagement newInstance( boolean withDefaults )
315 {
316 return newBuilder( withDefaults ).build();
317 }
318
319
320
321
322
323
324
325
326 @Nonnull
327 public static Builder newBuilder()
328 {
329 return newBuilder( true );
330 }
331
332
333
334
335
336
337
338 @Nonnull
339 public static Builder newBuilder( boolean withDefaults )
340 {
341 return new Builder( withDefaults );
342 }
343
344
345
346
347
348
349
350
351 @Nonnull
352 public static Builder newBuilder( DistributionManagement from )
353 {
354 return newBuilder( from, false );
355 }
356
357
358
359
360
361
362
363
364 @Nonnull
365 public static Builder newBuilder( DistributionManagement from, boolean forceCopy )
366 {
367 return new Builder( from, forceCopy );
368 }
369
370
371
372
373
374
375 @NotThreadSafe
376 public static class Builder
377 {
378 DistributionManagement base;
379 DeploymentRepository repository;
380 DeploymentRepository snapshotRepository;
381 Site site;
382 String downloadUrl;
383 Relocation relocation;
384 String status;
385 Map<Object, InputLocation> locations;
386
387 Builder( boolean withDefaults )
388 {
389 if ( withDefaults )
390 {
391 }
392 }
393
394 Builder( DistributionManagement base, boolean forceCopy )
395 {
396 if ( forceCopy )
397 {
398 this.repository = base.repository;
399 this.snapshotRepository = base.snapshotRepository;
400 this.site = base.site;
401 this.downloadUrl = base.downloadUrl;
402 this.relocation = base.relocation;
403 this.status = base.status;
404 }
405 else
406 {
407 this.base = base;
408 }
409 }
410
411 @Nonnull
412 public Builder repository( DeploymentRepository repository )
413 {
414 this.repository = repository;
415 return this;
416 }
417
418 @Nonnull
419 public Builder snapshotRepository( DeploymentRepository snapshotRepository )
420 {
421 this.snapshotRepository = snapshotRepository;
422 return this;
423 }
424
425 @Nonnull
426 public Builder site( Site site )
427 {
428 this.site = site;
429 return this;
430 }
431
432 @Nonnull
433 public Builder downloadUrl( String downloadUrl )
434 {
435 this.downloadUrl = downloadUrl;
436 return this;
437 }
438
439 @Nonnull
440 public Builder relocation( Relocation relocation )
441 {
442 this.relocation = relocation;
443 return this;
444 }
445
446 @Nonnull
447 public Builder status( String status )
448 {
449 this.status = status;
450 return this;
451 }
452
453
454 @Nonnull
455 public Builder location( Object key, InputLocation location )
456 {
457 if ( location != null )
458 {
459 if ( this.locations == null )
460 {
461 this.locations = new HashMap<>();
462 }
463 this.locations.put( key, location );
464 }
465 return this;
466 }
467
468 @Nonnull
469 public DistributionManagement build()
470 {
471 if ( base != null
472 && ( repository == null || repository == base.repository )
473 && ( snapshotRepository == null || snapshotRepository == base.snapshotRepository )
474 && ( site == null || site == base.site )
475 && ( downloadUrl == null || downloadUrl == base.downloadUrl )
476 && ( relocation == null || relocation == base.relocation )
477 && ( status == null || status == base.status )
478 )
479 {
480 return base;
481 }
482 Map<Object, InputLocation> locations = null;
483 InputLocation location = null;
484 InputLocation repositoryLocation = null;
485 InputLocation snapshotRepositoryLocation = null;
486 InputLocation siteLocation = null;
487 InputLocation downloadUrlLocation = null;
488 InputLocation relocationLocation = null;
489 InputLocation statusLocation = null;
490 if ( this.locations != null )
491 {
492 locations = this.locations;
493 location = locations.remove( "" );
494 repositoryLocation = locations.remove( "repository" );
495 snapshotRepositoryLocation = locations.remove( "snapshotRepository" );
496 siteLocation = locations.remove( "site" );
497 downloadUrlLocation = locations.remove( "downloadUrl" );
498 relocationLocation = locations.remove( "relocation" );
499 statusLocation = locations.remove( "status" );
500 }
501 return new DistributionManagement(
502 repository != null ? repository : ( base != null ? base.repository : null ),
503 snapshotRepository != null ? snapshotRepository : ( base != null ? base.snapshotRepository : null ),
504 site != null ? site : ( base != null ? base.site : null ),
505 downloadUrl != null ? downloadUrl : ( base != null ? base.downloadUrl : null ),
506 relocation != null ? relocation : ( base != null ? base.relocation : null ),
507 status != null ? status : ( base != null ? base.status : null ),
508 locations != null ? locations : ( base != null ? base.locations : null ),
509 location != null ? location : ( base != null ? base.location : null ),
510 repositoryLocation != null ? repositoryLocation : ( base != null ? base.repositoryLocation : null ),
511 snapshotRepositoryLocation != null ? snapshotRepositoryLocation : ( base != null ? base.snapshotRepositoryLocation : null ),
512 siteLocation != null ? siteLocation : ( base != null ? base.siteLocation : null ),
513 downloadUrlLocation != null ? downloadUrlLocation : ( base != null ? base.downloadUrlLocation : null ),
514 relocationLocation != null ? relocationLocation : ( base != null ? base.relocationLocation : null ),
515 statusLocation != null ? statusLocation : ( base != null ? base.statusLocation : null )
516 );
517 }
518 }
519
520 }