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 Scm
24 implements Serializable, InputLocationTracker
25 {
26
27
28
29
30
31
32
33
34
35
36 final String connection;
37
38
39
40
41
42
43 final String developerConnection;
44
45
46
47 final String tag;
48
49
50
51
52
53 final String url;
54
55
56
57
58
59
60
61 final String childScmConnectionInheritAppendPath;
62
63
64
65
66
67
68
69 final String childScmDeveloperConnectionInheritAppendPath;
70
71
72
73
74
75
76
77 final String childScmUrlInheritAppendPath;
78
79 final InputLocation location;
80
81 final InputLocation connectionLocation;
82
83 final InputLocation developerConnectionLocation;
84
85 final InputLocation tagLocation;
86
87 final InputLocation urlLocation;
88
89 final InputLocation childScmConnectionInheritAppendPathLocation;
90
91 final InputLocation childScmDeveloperConnectionInheritAppendPathLocation;
92
93 final InputLocation childScmUrlInheritAppendPathLocation;
94
95 final Map<Object, InputLocation> locations;
96
97
98
99
100
101 Scm(
102 String connection,
103 String developerConnection,
104 String tag,
105 String url,
106 String childScmConnectionInheritAppendPath,
107 String childScmDeveloperConnectionInheritAppendPath,
108 String childScmUrlInheritAppendPath,
109 Map<Object, InputLocation> locations,
110 InputLocation location,
111 InputLocation connectionLocation,
112 InputLocation developerConnectionLocation,
113 InputLocation tagLocation,
114 InputLocation urlLocation,
115 InputLocation childScmConnectionInheritAppendPathLocation,
116 InputLocation childScmDeveloperConnectionInheritAppendPathLocation,
117 InputLocation childScmUrlInheritAppendPathLocation
118 )
119 {
120 this.connection = connection;
121 this.developerConnection = developerConnection;
122 this.tag = tag;
123 this.url = url;
124 this.childScmConnectionInheritAppendPath = childScmConnectionInheritAppendPath;
125 this.childScmDeveloperConnectionInheritAppendPath = childScmDeveloperConnectionInheritAppendPath;
126 this.childScmUrlInheritAppendPath = childScmUrlInheritAppendPath;
127 this.locations = ImmutableCollections.copy( locations );
128 this.location = location;
129 this.connectionLocation = connectionLocation;
130 this.developerConnectionLocation = developerConnectionLocation;
131 this.tagLocation = tagLocation;
132 this.urlLocation = urlLocation;
133 this.childScmConnectionInheritAppendPathLocation = childScmConnectionInheritAppendPathLocation;
134 this.childScmDeveloperConnectionInheritAppendPathLocation = childScmDeveloperConnectionInheritAppendPathLocation;
135 this.childScmUrlInheritAppendPathLocation = childScmUrlInheritAppendPathLocation;
136 }
137
138
139
140
141
142
143
144
145
146
147
148
149
150 public String getConnection()
151 {
152 return this.connection;
153 }
154
155
156
157
158
159
160
161
162
163 public String getDeveloperConnection()
164 {
165 return this.developerConnection;
166 }
167
168
169
170
171
172
173 public String getTag()
174 {
175 return this.tag;
176 }
177
178
179
180
181
182
183
184
185 public String getUrl()
186 {
187 return this.url;
188 }
189
190
191
192
193
194
195
196
197
198
199 public String getChildScmConnectionInheritAppendPath()
200 {
201 return this.childScmConnectionInheritAppendPath;
202 }
203
204
205
206
207
208
209
210
211
212
213 public String getChildScmDeveloperConnectionInheritAppendPath()
214 {
215 return this.childScmDeveloperConnectionInheritAppendPath;
216 }
217
218
219
220
221
222
223
224
225
226
227 public String getChildScmUrlInheritAppendPath()
228 {
229 return this.childScmUrlInheritAppendPath;
230 }
231
232
233
234
235 public InputLocation getLocation( Object key )
236 {
237 if ( key instanceof String )
238 {
239 switch ( ( String ) key )
240 {
241 case "":
242 return location;
243 case "connection":
244 return connectionLocation;
245 case "developerConnection":
246 return developerConnectionLocation;
247 case "tag":
248 return tagLocation;
249 case "url":
250 return urlLocation;
251 case "childScmConnectionInheritAppendPath":
252 return childScmConnectionInheritAppendPathLocation;
253 case "childScmDeveloperConnectionInheritAppendPath":
254 return childScmDeveloperConnectionInheritAppendPathLocation;
255 case "childScmUrlInheritAppendPath":
256 return childScmUrlInheritAppendPathLocation;
257 }
258 }
259 return locations != null ? locations.get( key ) : null;
260 }
261
262
263
264
265
266
267 @Nonnull
268 public Builder with()
269 {
270 return newBuilder( this );
271 }
272
273
274
275
276
277
278 @Nonnull
279 public Scm withConnection( String connection )
280 {
281 return with().connection( connection ).build();
282 }
283
284
285
286
287
288
289 @Nonnull
290 public Scm withDeveloperConnection( String developerConnection )
291 {
292 return with().developerConnection( developerConnection ).build();
293 }
294
295
296
297
298
299
300 @Nonnull
301 public Scm withTag( String tag )
302 {
303 return with().tag( tag ).build();
304 }
305
306
307
308
309
310
311 @Nonnull
312 public Scm withUrl( String url )
313 {
314 return with().url( url ).build();
315 }
316
317
318
319
320
321
322 @Nonnull
323 public Scm withChildScmConnectionInheritAppendPath( String childScmConnectionInheritAppendPath )
324 {
325 return with().childScmConnectionInheritAppendPath( childScmConnectionInheritAppendPath ).build();
326 }
327
328
329
330
331
332
333 @Nonnull
334 public Scm withChildScmDeveloperConnectionInheritAppendPath( String childScmDeveloperConnectionInheritAppendPath )
335 {
336 return with().childScmDeveloperConnectionInheritAppendPath( childScmDeveloperConnectionInheritAppendPath ).build();
337 }
338
339
340
341
342
343
344 @Nonnull
345 public Scm withChildScmUrlInheritAppendPath( String childScmUrlInheritAppendPath )
346 {
347 return with().childScmUrlInheritAppendPath( childScmUrlInheritAppendPath ).build();
348 }
349
350
351
352
353
354
355
356
357 @Nonnull
358 public static Scm newInstance()
359 {
360 return newInstance( true );
361 }
362
363
364
365
366
367
368
369
370 @Nonnull
371 public static Scm newInstance( boolean withDefaults )
372 {
373 return newBuilder( withDefaults ).build();
374 }
375
376
377
378
379
380
381
382
383 @Nonnull
384 public static Builder newBuilder()
385 {
386 return newBuilder( true );
387 }
388
389
390
391
392
393
394
395 @Nonnull
396 public static Builder newBuilder( boolean withDefaults )
397 {
398 return new Builder( withDefaults );
399 }
400
401
402
403
404
405
406
407
408 @Nonnull
409 public static Builder newBuilder( Scm from )
410 {
411 return newBuilder( from, false );
412 }
413
414
415
416
417
418
419
420
421 @Nonnull
422 public static Builder newBuilder( Scm from, boolean forceCopy )
423 {
424 return new Builder( from, forceCopy );
425 }
426
427
428
429
430
431
432 @NotThreadSafe
433 public static class Builder
434 {
435 Scm base;
436 String connection;
437 String developerConnection;
438 String tag;
439 String url;
440 String childScmConnectionInheritAppendPath;
441 String childScmDeveloperConnectionInheritAppendPath;
442 String childScmUrlInheritAppendPath;
443 Map<Object, InputLocation> locations;
444
445 Builder( boolean withDefaults )
446 {
447 if ( withDefaults )
448 {
449 this.tag = "HEAD";
450 }
451 }
452
453 Builder( Scm base, boolean forceCopy )
454 {
455 if ( forceCopy )
456 {
457 this.connection = base.connection;
458 this.developerConnection = base.developerConnection;
459 this.tag = base.tag;
460 this.url = base.url;
461 this.childScmConnectionInheritAppendPath = base.childScmConnectionInheritAppendPath;
462 this.childScmDeveloperConnectionInheritAppendPath = base.childScmDeveloperConnectionInheritAppendPath;
463 this.childScmUrlInheritAppendPath = base.childScmUrlInheritAppendPath;
464 }
465 else
466 {
467 this.base = base;
468 }
469 }
470
471 @Nonnull
472 public Builder connection( String connection )
473 {
474 this.connection = connection;
475 return this;
476 }
477
478 @Nonnull
479 public Builder developerConnection( String developerConnection )
480 {
481 this.developerConnection = developerConnection;
482 return this;
483 }
484
485 @Nonnull
486 public Builder tag( String tag )
487 {
488 this.tag = tag;
489 return this;
490 }
491
492 @Nonnull
493 public Builder url( String url )
494 {
495 this.url = url;
496 return this;
497 }
498
499 @Nonnull
500 public Builder childScmConnectionInheritAppendPath( String childScmConnectionInheritAppendPath )
501 {
502 this.childScmConnectionInheritAppendPath = childScmConnectionInheritAppendPath;
503 return this;
504 }
505
506 @Nonnull
507 public Builder childScmDeveloperConnectionInheritAppendPath( String childScmDeveloperConnectionInheritAppendPath )
508 {
509 this.childScmDeveloperConnectionInheritAppendPath = childScmDeveloperConnectionInheritAppendPath;
510 return this;
511 }
512
513 @Nonnull
514 public Builder childScmUrlInheritAppendPath( String childScmUrlInheritAppendPath )
515 {
516 this.childScmUrlInheritAppendPath = childScmUrlInheritAppendPath;
517 return this;
518 }
519
520
521 @Nonnull
522 public Builder location( Object key, InputLocation location )
523 {
524 if ( location != null )
525 {
526 if ( this.locations == null )
527 {
528 this.locations = new HashMap<>();
529 }
530 this.locations.put( key, location );
531 }
532 return this;
533 }
534
535 @Nonnull
536 public Scm build()
537 {
538 if ( base != null
539 && ( connection == null || connection == base.connection )
540 && ( developerConnection == null || developerConnection == base.developerConnection )
541 && ( tag == null || tag == base.tag )
542 && ( url == null || url == base.url )
543 && ( childScmConnectionInheritAppendPath == null || childScmConnectionInheritAppendPath == base.childScmConnectionInheritAppendPath )
544 && ( childScmDeveloperConnectionInheritAppendPath == null || childScmDeveloperConnectionInheritAppendPath == base.childScmDeveloperConnectionInheritAppendPath )
545 && ( childScmUrlInheritAppendPath == null || childScmUrlInheritAppendPath == base.childScmUrlInheritAppendPath )
546 )
547 {
548 return base;
549 }
550 Map<Object, InputLocation> locations = null;
551 InputLocation location = null;
552 InputLocation connectionLocation = null;
553 InputLocation developerConnectionLocation = null;
554 InputLocation tagLocation = null;
555 InputLocation urlLocation = null;
556 InputLocation childScmConnectionInheritAppendPathLocation = null;
557 InputLocation childScmDeveloperConnectionInheritAppendPathLocation = null;
558 InputLocation childScmUrlInheritAppendPathLocation = null;
559 if ( this.locations != null )
560 {
561 locations = this.locations;
562 location = locations.remove( "" );
563 connectionLocation = locations.remove( "connection" );
564 developerConnectionLocation = locations.remove( "developerConnection" );
565 tagLocation = locations.remove( "tag" );
566 urlLocation = locations.remove( "url" );
567 childScmConnectionInheritAppendPathLocation = locations.remove( "childScmConnectionInheritAppendPath" );
568 childScmDeveloperConnectionInheritAppendPathLocation = locations.remove( "childScmDeveloperConnectionInheritAppendPath" );
569 childScmUrlInheritAppendPathLocation = locations.remove( "childScmUrlInheritAppendPath" );
570 }
571 return new Scm(
572 connection != null ? connection : ( base != null ? base.connection : null ),
573 developerConnection != null ? developerConnection : ( base != null ? base.developerConnection : null ),
574 tag != null ? tag : ( base != null ? base.tag : null ),
575 url != null ? url : ( base != null ? base.url : null ),
576 childScmConnectionInheritAppendPath != null ? childScmConnectionInheritAppendPath : ( base != null ? base.childScmConnectionInheritAppendPath : null ),
577 childScmDeveloperConnectionInheritAppendPath != null ? childScmDeveloperConnectionInheritAppendPath : ( base != null ? base.childScmDeveloperConnectionInheritAppendPath : null ),
578 childScmUrlInheritAppendPath != null ? childScmUrlInheritAppendPath : ( base != null ? base.childScmUrlInheritAppendPath : null ),
579 locations != null ? locations : ( base != null ? base.locations : null ),
580 location != null ? location : ( base != null ? base.location : null ),
581 connectionLocation != null ? connectionLocation : ( base != null ? base.connectionLocation : null ),
582 developerConnectionLocation != null ? developerConnectionLocation : ( base != null ? base.developerConnectionLocation : null ),
583 tagLocation != null ? tagLocation : ( base != null ? base.tagLocation : null ),
584 urlLocation != null ? urlLocation : ( base != null ? base.urlLocation : null ),
585 childScmConnectionInheritAppendPathLocation != null ? childScmConnectionInheritAppendPathLocation : ( base != null ? base.childScmConnectionInheritAppendPathLocation : null ),
586 childScmDeveloperConnectionInheritAppendPathLocation != null ? childScmDeveloperConnectionInheritAppendPathLocation : ( base != null ? base.childScmDeveloperConnectionInheritAppendPathLocation : null ),
587 childScmUrlInheritAppendPathLocation != null ? childScmUrlInheritAppendPathLocation : ( base != null ? base.childScmUrlInheritAppendPathLocation : null )
588 );
589 }
590 }
591
592
593
594
595 public boolean isChildScmConnectionInheritAppendPath()
596 {
597 return ( getChildScmConnectionInheritAppendPath() != null ) ? Boolean.parseBoolean( getChildScmConnectionInheritAppendPath() ) : true;
598 }
599
600 public boolean isChildScmDeveloperConnectionInheritAppendPath()
601 {
602 return ( getChildScmDeveloperConnectionInheritAppendPath() != null ) ? Boolean.parseBoolean( getChildScmDeveloperConnectionInheritAppendPath() ) : true;
603 }
604
605 public boolean isChildScmUrlInheritAppendPath()
606 {
607 return ( getChildScmUrlInheritAppendPath() != null ) ? Boolean.parseBoolean( getChildScmUrlInheritAppendPath() ) : true;
608 }
609
610
611
612 }