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