View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //   Generated by Maven, any modifications will be overwritten.
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   * The {@code <scm>} element contains informations required to the SCM
19   * (Source Control Management) of the project.
20   */
21  @Experimental
22  @Generated @ThreadSafe @Immutable
23  public class Scm
24      implements Serializable, InputLocationTracker
25  {
26      /**
27       * The source control management system URL
28       * that describes the repository and how to connect to the
29       * repository. For more information, see the
30       * <a href="https://maven.apache.org/scm/scm-url-format.html">URL format</a>
31       * and <a href="https://maven.apache.org/scm/scms-overview.html">list of supported SCMs</a>.
32       * This connection is read-only.
33       * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
34       * scm's {@code child.scm.connection.inherit.append.path="false"}
35       */
36      final String connection;
37      /**
38       * Just like {@code connection}, but for developers, i.e. this scm connection
39       * will not be read only.
40       * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
41       * scm's {@code child.scm.developerConnection.inherit.append.path="false"}
42       */
43      final String developerConnection;
44      /**
45       * The tag of current code. By default, it's set to HEAD during development.
46       */
47      final String tag;
48      /**
49       * The URL to the project's browsable SCM repository, such as ViewVC or Fisheye.
50       * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
51       * scm's {@code child.scm.url.inherit.append.path="false"}
52       */
53      final String url;
54      /**
55       * When children inherit from scm connection, append path or not? Note: While the type
56       * of this field is {@code String} for technical reasons, the semantic type is actually
57       * {@code Boolean}
58       * <br><b>Default value is</b>: {@code true}
59       * <br><b>Since</b>: Maven 3.6.1
60       */
61      final String childScmConnectionInheritAppendPath;
62      /**
63       * When children inherit from scm developer connection, append path or not? Note: While the type
64       * of this field is {@code String} for technical reasons, the semantic type is actually
65       * {@code Boolean}
66       * <br><b>Default value is</b>: {@code true}
67       * <br><b>Since</b>: Maven 3.6.1
68       */
69      final String childScmDeveloperConnectionInheritAppendPath;
70      /**
71       * When children inherit from scm url, append path or not? Note: While the type
72       * of this field is {@code String} for technical reasons, the semantic type is actually
73       * {@code Boolean}
74       * <br><b>Default value is</b>: {@code true}
75       * <br><b>Since</b>: Maven 3.6.1
76       */
77      final String childScmUrlInheritAppendPath;
78      /** Location of the xml element for this object. */
79      final InputLocation location;
80      /** Location of the xml element for the field connection. */
81      final InputLocation connectionLocation;
82      /** Location of the xml element for the field developerConnection. */
83      final InputLocation developerConnectionLocation;
84      /** Location of the xml element for the field tag. */
85      final InputLocation tagLocation;
86      /** Location of the xml element for the field url. */
87      final InputLocation urlLocation;
88      /** Location of the xml element for the field childScmConnectionInheritAppendPath. */
89      final InputLocation childScmConnectionInheritAppendPathLocation;
90      /** Location of the xml element for the field childScmDeveloperConnectionInheritAppendPath. */
91      final InputLocation childScmDeveloperConnectionInheritAppendPathLocation;
92      /** Location of the xml element for the field childScmUrlInheritAppendPath. */
93      final InputLocation childScmUrlInheritAppendPathLocation;
94      /** Other locations */
95      final Map<Object, InputLocation> locations;
96  
97      /**
98        * Constructor for this class, package protected.
99        * @see Builder#build()
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      * The source control management system URL
140      * that describes the repository and how to connect to the
141      * repository. For more information, see the
142      * <a href="https://maven.apache.org/scm/scm-url-format.html">URL format</a>
143      * and <a href="https://maven.apache.org/scm/scms-overview.html">list of supported SCMs</a>.
144      * This connection is read-only.
145      * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
146      * scm's {@code child.scm.connection.inherit.append.path="false"}
147      *
148      * @return a {@code String}
149      */
150     public String getConnection()
151     {
152         return this.connection;
153     }
154 
155     /**
156      * Just like {@code connection}, but for developers, i.e. this scm connection
157      * will not be read only.
158      * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
159      * scm's {@code child.scm.developerConnection.inherit.append.path="false"}
160      *
161      * @return a {@code String}
162      */
163     public String getDeveloperConnection()
164     {
165         return this.developerConnection;
166     }
167 
168     /**
169      * The tag of current code. By default, it's set to HEAD during development.
170      *
171      * @return a {@code String}
172      */
173     public String getTag()
174     {
175         return this.tag;
176     }
177 
178     /**
179      * The URL to the project's browsable SCM repository, such as ViewVC or Fisheye.
180      * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
181      * scm's {@code child.scm.url.inherit.append.path="false"}
182      *
183      * @return a {@code String}
184      */
185     public String getUrl()
186     {
187         return this.url;
188     }
189 
190     /**
191      * When children inherit from scm connection, append path or not? Note: While the type
192      * of this field is {@code String} for technical reasons, the semantic type is actually
193      * {@code Boolean}
194      * <br><b>Default value is</b>: {@code true}
195      * <br><b>Since</b>: Maven 3.6.1
196      *
197      * @return a {@code String}
198      */
199     public String getChildScmConnectionInheritAppendPath()
200     {
201         return this.childScmConnectionInheritAppendPath;
202     }
203 
204     /**
205      * When children inherit from scm developer connection, append path or not? Note: While the type
206      * of this field is {@code String} for technical reasons, the semantic type is actually
207      * {@code Boolean}
208      * <br><b>Default value is</b>: {@code true}
209      * <br><b>Since</b>: Maven 3.6.1
210      *
211      * @return a {@code String}
212      */
213     public String getChildScmDeveloperConnectionInheritAppendPath()
214     {
215         return this.childScmDeveloperConnectionInheritAppendPath;
216     }
217 
218     /**
219      * When children inherit from scm url, append path or not? Note: While the type
220      * of this field is {@code String} for technical reasons, the semantic type is actually
221      * {@code Boolean}
222      * <br><b>Default value is</b>: {@code true}
223      * <br><b>Since</b>: Maven 3.6.1
224      *
225      * @return a {@code String}
226      */
227     public String getChildScmUrlInheritAppendPath()
228     {
229         return this.childScmUrlInheritAppendPath;
230     }
231 
232     /**
233      * Gets the location of the specified field in the input source.
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      * Creates a new builder with this object as the basis.
264      *
265      * @return a {@code Builder}
266      */
267     @Nonnull
268     public Builder with()
269     {
270         return newBuilder( this );
271     }
272     /**
273      * Creates a new {@code Scm} instance using the specified connection.
274      *
275      * @param connection the new {@code String} to use
276      * @return a {@code Scm} with the specified connection
277      */
278     @Nonnull
279     public Scm withConnection( String connection )
280     {
281         return with().connection( connection ).build();
282     }
283     /**
284      * Creates a new {@code Scm} instance using the specified developerConnection.
285      *
286      * @param developerConnection the new {@code String} to use
287      * @return a {@code Scm} with the specified developerConnection
288      */
289     @Nonnull
290     public Scm withDeveloperConnection( String developerConnection )
291     {
292         return with().developerConnection( developerConnection ).build();
293     }
294     /**
295      * Creates a new {@code Scm} instance using the specified tag.
296      *
297      * @param tag the new {@code String} to use
298      * @return a {@code Scm} with the specified tag
299      */
300     @Nonnull
301     public Scm withTag( String tag )
302     {
303         return with().tag( tag ).build();
304     }
305     /**
306      * Creates a new {@code Scm} instance using the specified url.
307      *
308      * @param url the new {@code String} to use
309      * @return a {@code Scm} with the specified url
310      */
311     @Nonnull
312     public Scm withUrl( String url )
313     {
314         return with().url( url ).build();
315     }
316     /**
317      * Creates a new {@code Scm} instance using the specified childScmConnectionInheritAppendPath.
318      *
319      * @param childScmConnectionInheritAppendPath the new {@code String} to use
320      * @return a {@code Scm} with the specified childScmConnectionInheritAppendPath
321      */
322     @Nonnull
323     public Scm withChildScmConnectionInheritAppendPath( String childScmConnectionInheritAppendPath )
324     {
325         return with().childScmConnectionInheritAppendPath( childScmConnectionInheritAppendPath ).build();
326     }
327     /**
328      * Creates a new {@code Scm} instance using the specified childScmDeveloperConnectionInheritAppendPath.
329      *
330      * @param childScmDeveloperConnectionInheritAppendPath the new {@code String} to use
331      * @return a {@code Scm} with the specified childScmDeveloperConnectionInheritAppendPath
332      */
333     @Nonnull
334     public Scm withChildScmDeveloperConnectionInheritAppendPath( String childScmDeveloperConnectionInheritAppendPath )
335     {
336         return with().childScmDeveloperConnectionInheritAppendPath( childScmDeveloperConnectionInheritAppendPath ).build();
337     }
338     /**
339      * Creates a new {@code Scm} instance using the specified childScmUrlInheritAppendPath.
340      *
341      * @param childScmUrlInheritAppendPath the new {@code String} to use
342      * @return a {@code Scm} with the specified childScmUrlInheritAppendPath
343      */
344     @Nonnull
345     public Scm withChildScmUrlInheritAppendPath( String childScmUrlInheritAppendPath )
346     {
347         return with().childScmUrlInheritAppendPath( childScmUrlInheritAppendPath ).build();
348     }
349 
350     /**
351      * Creates a new {@code Scm} instance.
352      * Equivalent to {@code newInstance( true )}.
353      * @see #newInstance(boolean)
354      *
355      * @return a new {@code Scm}
356      */
357     @Nonnull
358     public static Scm newInstance()
359     {
360         return newInstance( true );
361     }
362 
363     /**
364      * Creates a new {@code Scm} instance using default values or not.
365      * Equivalent to {@code newBuilder( withDefaults ).build()}.
366      *
367      * @param withDefaults the boolean indicating whether default values should be used
368      * @return a new {@code Scm}
369      */
370     @Nonnull
371     public static Scm newInstance( boolean withDefaults )
372     {
373         return newBuilder( withDefaults ).build();
374     }
375 
376     /**
377      * Creates a new {@code Scm} builder instance.
378      * Equivalent to {@code newBuilder( true )}.
379      * @see #newBuilder(boolean)
380      *
381      * @return a new {@code Builder}
382      */
383     @Nonnull
384     public static Builder newBuilder()
385     {
386         return newBuilder( true );
387     }
388 
389     /**
390      * Creates a new {@code Scm} builder instance using default values or not.
391      *
392      * @param withDefaults the boolean indicating whether default values should be used
393      * @return a new {@code Builder}
394      */
395     @Nonnull
396     public static Builder newBuilder( boolean withDefaults )
397     {
398         return new Builder( withDefaults );
399     }
400 
401     /**
402      * Creates a new {@code Scm} builder instance using the specified object as a basis.
403      * Equivalent to {@code newBuilder( from, false )}.
404      *
405      * @param from the {@code Scm} instance to use as a basis
406      * @return a new {@code Builder}
407      */
408     @Nonnull
409     public static Builder newBuilder( Scm from )
410     {
411         return newBuilder( from, false );
412     }
413 
414     /**
415      * Creates a new {@code Scm} builder instance using the specified object as a basis.
416      *
417      * @param from the {@code Scm} instance to use as a basis
418      * @param forceCopy the boolean indicating if a copy should be forced
419      * @return a new {@code Builder}
420      */
421     @Nonnull
422     public static Builder newBuilder( Scm from, boolean forceCopy )
423     {
424         return new Builder( from, forceCopy );
425     }
426 
427     /**
428      * Builder class used to create Scm instances.
429      * @see #with()
430      * @see #newBuilder()
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 }