View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //  Generated by Modello Velocity from model.vm
3   //  template, any modifications will be overwritten.
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   * The {@code <scm>} element contains informations required to the SCM
20   * (Source Control Management) of the project.
21   */
22  @Experimental
23  @Generated @ThreadSafe @Immutable
24  public class Scm
25      implements Serializable, InputLocationTracker
26  {
27      /**
28       * The source control management system URL
29       * that describes the repository and how to connect to the
30       * repository. For more information, see the
31       * <a href="https://maven.apache.org/scm/scm-url-format.html">URL format</a>
32       * and <a href="https://maven.apache.org/scm/scms-overview.html">list of supported SCMs</a>.
33       * This connection is read-only.
34       * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
35       * scm's {@code child.scm.connection.inherit.append.path="false"}
36       */
37      final String connection;
38      /**
39       * Just like {@code connection}, but for developers, i.e. this scm connection
40       * will not be read only.
41       * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
42       * scm's {@code child.scm.developerConnection.inherit.append.path="false"}
43       */
44      final String developerConnection;
45      /**
46       * The tag of current code. By default, it's set to HEAD during development.
47       */
48      final String tag;
49      /**
50       * The URL to the project's browsable SCM repository, such as ViewVC or Fisheye.
51       * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
52       * scm's {@code child.scm.url.inherit.append.path="false"}
53       */
54      final String url;
55      /**
56       * When children inherit from scm connection, append path or not? Note: While the type
57       * of this field is {@code String} for technical reasons, the semantic type is actually
58       * {@code Boolean}
59       * <br><b>Default value is</b>: {@code true}
60       * <br><b>Since</b>: Maven 3.6.1
61       */
62      final String childScmConnectionInheritAppendPath;
63      /**
64       * When children inherit from scm developer connection, append path or not? Note: While the type
65       * of this field is {@code String} for technical reasons, the semantic type is actually
66       * {@code Boolean}
67       * <br><b>Default value is</b>: {@code true}
68       * <br><b>Since</b>: Maven 3.6.1
69       */
70      final String childScmDeveloperConnectionInheritAppendPath;
71      /**
72       * When children inherit from scm url, append path or not? Note: While the type
73       * of this field is {@code String} for technical reasons, the semantic type is actually
74       * {@code Boolean}
75       * <br><b>Default value is</b>: {@code true}
76       * <br><b>Since</b>: Maven 3.6.1
77       */
78      final String childScmUrlInheritAppendPath;
79      /** Location of the xml element for this object. */
80      final InputLocation location;
81      /** Location of the xml element for the field connection. */
82      final InputLocation connectionLocation;
83      /** Location of the xml element for the field developerConnection. */
84      final InputLocation developerConnectionLocation;
85      /** Location of the xml element for the field tag. */
86      final InputLocation tagLocation;
87      /** Location of the xml element for the field url. */
88      final InputLocation urlLocation;
89      /** Location of the xml element for the field childScmConnectionInheritAppendPath. */
90      final InputLocation childScmConnectionInheritAppendPathLocation;
91      /** Location of the xml element for the field childScmDeveloperConnectionInheritAppendPath. */
92      final InputLocation childScmDeveloperConnectionInheritAppendPathLocation;
93      /** Location of the xml element for the field childScmUrlInheritAppendPath. */
94      final InputLocation childScmUrlInheritAppendPathLocation;
95      /** Other locations */
96      final Map<Object, InputLocation> locations;
97  
98      /**
99        * Constructor for this class, package protected.
100       * @see Builder#build()
101       */
102     Scm(
103         String connection,
104         String developerConnection,
105         String tag,
106         String url,
107         String childScmConnectionInheritAppendPath,
108         String childScmDeveloperConnectionInheritAppendPath,
109         String childScmUrlInheritAppendPath,
110         Map<Object, InputLocation> locations,
111         InputLocation location,
112         InputLocation connectionLocation,
113         InputLocation developerConnectionLocation,
114         InputLocation tagLocation,
115         InputLocation urlLocation,
116         InputLocation childScmConnectionInheritAppendPathLocation,
117         InputLocation childScmDeveloperConnectionInheritAppendPathLocation,
118         InputLocation childScmUrlInheritAppendPathLocation
119     )
120     {
121         this.connection = connection;
122         this.developerConnection = developerConnection;
123         this.tag = tag;
124         this.url = url;
125         this.childScmConnectionInheritAppendPath = childScmConnectionInheritAppendPath;
126         this.childScmDeveloperConnectionInheritAppendPath = childScmDeveloperConnectionInheritAppendPath;
127         this.childScmUrlInheritAppendPath = childScmUrlInheritAppendPath;
128         this.locations = ImmutableCollections.copy( locations );
129         this.location = location;
130         this.connectionLocation = connectionLocation;
131         this.developerConnectionLocation = developerConnectionLocation;
132         this.tagLocation = tagLocation;
133         this.urlLocation = urlLocation;
134         this.childScmConnectionInheritAppendPathLocation = childScmConnectionInheritAppendPathLocation;
135         this.childScmDeveloperConnectionInheritAppendPathLocation = childScmDeveloperConnectionInheritAppendPathLocation;
136         this.childScmUrlInheritAppendPathLocation = childScmUrlInheritAppendPathLocation;
137     }
138 
139     /**
140      * The source control management system URL
141      * that describes the repository and how to connect to the
142      * repository. For more information, see the
143      * <a href="https://maven.apache.org/scm/scm-url-format.html">URL format</a>
144      * and <a href="https://maven.apache.org/scm/scms-overview.html">list of supported SCMs</a>.
145      * This connection is read-only.
146      * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
147      * scm's {@code child.scm.connection.inherit.append.path="false"}
148      *
149      * @return a {@code String}
150      */
151     public String getConnection()
152     {
153         return this.connection;
154     }
155 
156     /**
157      * Just like {@code connection}, but for developers, i.e. this scm connection
158      * will not be read only.
159      * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
160      * scm's {@code child.scm.developerConnection.inherit.append.path="false"}
161      *
162      * @return a {@code String}
163      */
164     public String getDeveloperConnection()
165     {
166         return this.developerConnection;
167     }
168 
169     /**
170      * The tag of current code. By default, it's set to HEAD during development.
171      *
172      * @return a {@code String}
173      */
174     public String getTag()
175     {
176         return this.tag;
177     }
178 
179     /**
180      * The URL to the project's browsable SCM repository, such as ViewVC or Fisheye.
181      * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
182      * scm's {@code child.scm.url.inherit.append.path="false"}
183      *
184      * @return a {@code String}
185      */
186     public String getUrl()
187     {
188         return this.url;
189     }
190 
191     /**
192      * When children inherit from scm connection, append path or not? Note: While the type
193      * of this field is {@code String} for technical reasons, the semantic type is actually
194      * {@code Boolean}
195      * <br><b>Default value is</b>: {@code true}
196      * <br><b>Since</b>: Maven 3.6.1
197      *
198      * @return a {@code String}
199      */
200     public String getChildScmConnectionInheritAppendPath()
201     {
202         return this.childScmConnectionInheritAppendPath;
203     }
204 
205     /**
206      * When children inherit from scm developer connection, append path or not? Note: While the type
207      * of this field is {@code String} for technical reasons, the semantic type is actually
208      * {@code Boolean}
209      * <br><b>Default value is</b>: {@code true}
210      * <br><b>Since</b>: Maven 3.6.1
211      *
212      * @return a {@code String}
213      */
214     public String getChildScmDeveloperConnectionInheritAppendPath()
215     {
216         return this.childScmDeveloperConnectionInheritAppendPath;
217     }
218 
219     /**
220      * When children inherit from scm url, append path or not? Note: While the type
221      * of this field is {@code String} for technical reasons, the semantic type is actually
222      * {@code Boolean}
223      * <br><b>Default value is</b>: {@code true}
224      * <br><b>Since</b>: Maven 3.6.1
225      *
226      * @return a {@code String}
227      */
228     public String getChildScmUrlInheritAppendPath()
229     {
230         return this.childScmUrlInheritAppendPath;
231     }
232 
233     /**
234      * Gets the location of the specified field in the input source.
235      */
236     public InputLocation getLocation( Object key )
237     {
238         if ( key instanceof String )
239         {
240             switch ( ( String ) key )
241             {
242                 case "":
243                     return location;
244                 case "connection":
245                     return connectionLocation;
246                 case "developerConnection":
247                     return developerConnectionLocation;
248                 case "tag":
249                     return tagLocation;
250                 case "url":
251                     return urlLocation;
252                 case "childScmConnectionInheritAppendPath":
253                     return childScmConnectionInheritAppendPathLocation;
254                 case "childScmDeveloperConnectionInheritAppendPath":
255                     return childScmDeveloperConnectionInheritAppendPathLocation;
256                 case "childScmUrlInheritAppendPath":
257                     return childScmUrlInheritAppendPathLocation;
258             }
259         }
260         return locations != null ? locations.get( key ) : null;
261     }
262 
263     /**
264      * Creates a new builder with this object as the basis.
265      *
266      * @return a {@code Builder}
267      */
268     @Nonnull
269     public Builder with()
270     {
271         return newBuilder( this );
272     }
273     /**
274      * Creates a new {@code Scm} instance using the specified connection.
275      *
276      * @param connection the new {@code String} to use
277      * @return a {@code Scm} with the specified connection
278      */
279     @Nonnull
280     public Scm withConnection( String connection )
281     {
282         return with().connection( connection ).build();
283     }
284     /**
285      * Creates a new {@code Scm} instance using the specified developerConnection.
286      *
287      * @param developerConnection the new {@code String} to use
288      * @return a {@code Scm} with the specified developerConnection
289      */
290     @Nonnull
291     public Scm withDeveloperConnection( String developerConnection )
292     {
293         return with().developerConnection( developerConnection ).build();
294     }
295     /**
296      * Creates a new {@code Scm} instance using the specified tag.
297      *
298      * @param tag the new {@code String} to use
299      * @return a {@code Scm} with the specified tag
300      */
301     @Nonnull
302     public Scm withTag( String tag )
303     {
304         return with().tag( tag ).build();
305     }
306     /**
307      * Creates a new {@code Scm} instance using the specified url.
308      *
309      * @param url the new {@code String} to use
310      * @return a {@code Scm} with the specified url
311      */
312     @Nonnull
313     public Scm withUrl( String url )
314     {
315         return with().url( url ).build();
316     }
317     /**
318      * Creates a new {@code Scm} instance using the specified childScmConnectionInheritAppendPath.
319      *
320      * @param childScmConnectionInheritAppendPath the new {@code String} to use
321      * @return a {@code Scm} with the specified childScmConnectionInheritAppendPath
322      */
323     @Nonnull
324     public Scm withChildScmConnectionInheritAppendPath( String childScmConnectionInheritAppendPath )
325     {
326         return with().childScmConnectionInheritAppendPath( childScmConnectionInheritAppendPath ).build();
327     }
328     /**
329      * Creates a new {@code Scm} instance using the specified childScmDeveloperConnectionInheritAppendPath.
330      *
331      * @param childScmDeveloperConnectionInheritAppendPath the new {@code String} to use
332      * @return a {@code Scm} with the specified childScmDeveloperConnectionInheritAppendPath
333      */
334     @Nonnull
335     public Scm withChildScmDeveloperConnectionInheritAppendPath( String childScmDeveloperConnectionInheritAppendPath )
336     {
337         return with().childScmDeveloperConnectionInheritAppendPath( childScmDeveloperConnectionInheritAppendPath ).build();
338     }
339     /**
340      * Creates a new {@code Scm} instance using the specified childScmUrlInheritAppendPath.
341      *
342      * @param childScmUrlInheritAppendPath the new {@code String} to use
343      * @return a {@code Scm} with the specified childScmUrlInheritAppendPath
344      */
345     @Nonnull
346     public Scm withChildScmUrlInheritAppendPath( String childScmUrlInheritAppendPath )
347     {
348         return with().childScmUrlInheritAppendPath( childScmUrlInheritAppendPath ).build();
349     }
350 
351     /**
352      * Creates a new {@code Scm} instance.
353      * Equivalent to {@code newInstance( true )}.
354      * @see #newInstance(boolean)
355      *
356      * @return a new {@code Scm}
357      */
358     @Nonnull
359     public static Scm newInstance()
360     {
361         return newInstance( true );
362     }
363 
364     /**
365      * Creates a new {@code Scm} instance using default values or not.
366      * Equivalent to {@code newBuilder( withDefaults ).build()}.
367      *
368      * @param withDefaults the boolean indicating whether default values should be used
369      * @return a new {@code Scm}
370      */
371     @Nonnull
372     public static Scm newInstance( boolean withDefaults )
373     {
374         return newBuilder( withDefaults ).build();
375     }
376 
377     /**
378      * Creates a new {@code Scm} builder instance.
379      * Equivalent to {@code newBuilder( true )}.
380      * @see #newBuilder(boolean)
381      *
382      * @return a new {@code Builder}
383      */
384     @Nonnull
385     public static Builder newBuilder()
386     {
387         return newBuilder( true );
388     }
389 
390     /**
391      * Creates a new {@code Scm} builder instance using default values or not.
392      *
393      * @param withDefaults the boolean indicating whether default values should be used
394      * @return a new {@code Builder}
395      */
396     @Nonnull
397     public static Builder newBuilder( boolean withDefaults )
398     {
399         return new Builder( withDefaults );
400     }
401 
402     /**
403      * Creates a new {@code Scm} builder instance using the specified object as a basis.
404      * Equivalent to {@code newBuilder( from, false )}.
405      *
406      * @param from the {@code Scm} instance to use as a basis
407      * @return a new {@code Builder}
408      */
409     @Nonnull
410     public static Builder newBuilder( Scm from )
411     {
412         return newBuilder( from, false );
413     }
414 
415     /**
416      * Creates a new {@code Scm} builder instance using the specified object as a basis.
417      *
418      * @param from the {@code Scm} instance to use as a basis
419      * @param forceCopy the boolean indicating if a copy should be forced
420      * @return a new {@code Builder}
421      */
422     @Nonnull
423     public static Builder newBuilder( Scm from, boolean forceCopy )
424     {
425         return new Builder( from, forceCopy );
426     }
427 
428     /**
429      * Builder class used to create Scm instances.
430      * @see #with()
431      * @see #newBuilder()
432      */
433     @NotThreadSafe
434     public static class Builder
435     {
436         Scm base;
437         String connection;
438         String developerConnection;
439         String tag;
440         String url;
441         String childScmConnectionInheritAppendPath;
442         String childScmDeveloperConnectionInheritAppendPath;
443         String childScmUrlInheritAppendPath;
444         Map<Object, InputLocation> locations;
445 
446         Builder( boolean withDefaults )
447         {
448             if ( withDefaults )
449             {
450                 this.tag = "HEAD";
451             }
452         }
453 
454         Builder( Scm base, boolean forceCopy )
455         {
456             if ( forceCopy )
457             {
458                 this.connection = base.connection;
459                 this.developerConnection = base.developerConnection;
460                 this.tag = base.tag;
461                 this.url = base.url;
462                 this.childScmConnectionInheritAppendPath = base.childScmConnectionInheritAppendPath;
463                 this.childScmDeveloperConnectionInheritAppendPath = base.childScmDeveloperConnectionInheritAppendPath;
464                 this.childScmUrlInheritAppendPath = base.childScmUrlInheritAppendPath;
465             }
466             else
467             {
468                 this.base = base;
469             }
470         }
471 
472         @Nonnull
473         public Builder connection( String connection )
474         {
475             this.connection = connection;
476             return this;
477         }
478 
479         @Nonnull
480         public Builder developerConnection( String developerConnection )
481         {
482             this.developerConnection = developerConnection;
483             return this;
484         }
485 
486         @Nonnull
487         public Builder tag( String tag )
488         {
489             this.tag = tag;
490             return this;
491         }
492 
493         @Nonnull
494         public Builder url( String url )
495         {
496             this.url = url;
497             return this;
498         }
499 
500         @Nonnull
501         public Builder childScmConnectionInheritAppendPath( String childScmConnectionInheritAppendPath )
502         {
503             this.childScmConnectionInheritAppendPath = childScmConnectionInheritAppendPath;
504             return this;
505         }
506 
507         @Nonnull
508         public Builder childScmDeveloperConnectionInheritAppendPath( String childScmDeveloperConnectionInheritAppendPath )
509         {
510             this.childScmDeveloperConnectionInheritAppendPath = childScmDeveloperConnectionInheritAppendPath;
511             return this;
512         }
513 
514         @Nonnull
515         public Builder childScmUrlInheritAppendPath( String childScmUrlInheritAppendPath )
516         {
517             this.childScmUrlInheritAppendPath = childScmUrlInheritAppendPath;
518             return this;
519         }
520 
521 
522         @Nonnull
523         public Builder location( Object key, InputLocation location )
524         {
525             if ( location != null )
526             {
527                 if ( this.locations == null )
528                 {
529                     this.locations = new HashMap<>();
530                 }
531                 this.locations.put( key, location );
532             }
533             return this;
534         }
535 
536         @Nonnull
537         public Scm build()
538         {
539             if ( base != null
540                     && ( connection == null || connection == base.connection )
541                     && ( developerConnection == null || developerConnection == base.developerConnection )
542                     && ( tag == null || tag == base.tag )
543                     && ( url == null || url == base.url )
544                     && ( childScmConnectionInheritAppendPath == null || childScmConnectionInheritAppendPath == base.childScmConnectionInheritAppendPath )
545                     && ( childScmDeveloperConnectionInheritAppendPath == null || childScmDeveloperConnectionInheritAppendPath == base.childScmDeveloperConnectionInheritAppendPath )
546                     && ( childScmUrlInheritAppendPath == null || childScmUrlInheritAppendPath == base.childScmUrlInheritAppendPath )
547             )
548             {
549                 return base;
550             }
551             Map<Object, InputLocation> locations = null;
552             InputLocation location = null;
553             InputLocation connectionLocation = null;
554             InputLocation developerConnectionLocation = null;
555             InputLocation tagLocation = null;
556             InputLocation urlLocation = null;
557             InputLocation childScmConnectionInheritAppendPathLocation = null;
558             InputLocation childScmDeveloperConnectionInheritAppendPathLocation = null;
559             InputLocation childScmUrlInheritAppendPathLocation = null;
560             if ( this.locations != null )
561             {
562                 locations = this.locations;
563                 location = locations.remove( "" );
564                 connectionLocation = locations.remove( "connection" );
565                 developerConnectionLocation = locations.remove( "developerConnection" );
566                 tagLocation = locations.remove( "tag" );
567                 urlLocation = locations.remove( "url" );
568                 childScmConnectionInheritAppendPathLocation = locations.remove( "childScmConnectionInheritAppendPath" );
569                 childScmDeveloperConnectionInheritAppendPathLocation = locations.remove( "childScmDeveloperConnectionInheritAppendPath" );
570                 childScmUrlInheritAppendPathLocation = locations.remove( "childScmUrlInheritAppendPath" );
571             }
572             return new Scm(
573                 connection != null ? connection : ( base != null ? base.connection : null ),
574                 developerConnection != null ? developerConnection : ( base != null ? base.developerConnection : null ),
575                 tag != null ? tag : ( base != null ? base.tag : null ),
576                 url != null ? url : ( base != null ? base.url : null ),
577                 childScmConnectionInheritAppendPath != null ? childScmConnectionInheritAppendPath : ( base != null ? base.childScmConnectionInheritAppendPath : null ),
578                 childScmDeveloperConnectionInheritAppendPath != null ? childScmDeveloperConnectionInheritAppendPath : ( base != null ? base.childScmDeveloperConnectionInheritAppendPath : null ),
579                 childScmUrlInheritAppendPath != null ? childScmUrlInheritAppendPath : ( base != null ? base.childScmUrlInheritAppendPath : null ),
580                 locations != null ? locations : ( base != null ? base.locations : null ),
581                 location != null ? location : ( base != null ? base.location : null ),
582                 connectionLocation != null ? connectionLocation : ( base != null ? base.connectionLocation : null ),
583                 developerConnectionLocation != null ? developerConnectionLocation : ( base != null ? base.developerConnectionLocation : null ),
584                 tagLocation != null ? tagLocation : ( base != null ? base.tagLocation : null ),
585                 urlLocation != null ? urlLocation : ( base != null ? base.urlLocation : null ),
586                 childScmConnectionInheritAppendPathLocation != null ? childScmConnectionInheritAppendPathLocation : ( base != null ? base.childScmConnectionInheritAppendPathLocation : null ),
587                 childScmDeveloperConnectionInheritAppendPathLocation != null ? childScmDeveloperConnectionInheritAppendPathLocation : ( base != null ? base.childScmDeveloperConnectionInheritAppendPathLocation : null ),
588                 childScmUrlInheritAppendPathLocation != null ? childScmUrlInheritAppendPathLocation : ( base != null ? base.childScmUrlInheritAppendPathLocation : null )
589             );
590         }
591     }
592 
593 
594             
595 
596     public boolean isChildScmConnectionInheritAppendPath()
597     {
598         return ( getChildScmConnectionInheritAppendPath() != null ) ? Boolean.parseBoolean( getChildScmConnectionInheritAppendPath() ) : true;
599     }
600 
601     public boolean isChildScmDeveloperConnectionInheritAppendPath()
602     {
603         return ( getChildScmDeveloperConnectionInheritAppendPath() != null ) ? Boolean.parseBoolean( getChildScmDeveloperConnectionInheritAppendPath() ) : true;
604     }
605 
606     public boolean isChildScmUrlInheritAppendPath()
607     {
608         return ( getChildScmUrlInheritAppendPath() != null ) ? Boolean.parseBoolean( getChildScmUrlInheritAppendPath() ) : true;
609     }
610 
611             
612           
613 
614             
615     /**
616      * @see java.lang.Object#toString()
617      */
618     public String toString()
619     {
620         return "Scm {connection=" + getConnection() + "}";
621     }
622             
623           
624 }