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   * Contains the information needed for deploying websites.
19   */
20  @Experimental
21  @Generated @ThreadSafe @Immutable
22  public class Site
23      implements Serializable, InputLocationTracker
24  {
25      /**
26       * A unique identifier for a deployment location. This is used to match the
27       * site to configuration in the {@code settings.xml} file, for example.
28       */
29      final String id;
30      /**
31       * Human readable name of the deployment location.
32       */
33      final String name;
34      /**
35       * The url of the location where website is deployed, in the form {@code protocol://hostname/path}.
36       * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
37       * site's {@code child.site.url.inherit.append.path="false"}
38       */
39      final String url;
40      /**
41       * When children inherit from distribution management site url, append path or not? Note: While the type
42       * of this field is {@code String} for technical reasons, the semantic type is actually
43       * {@code Boolean}
44       * <br><b>Default value is</b>: {@code true}
45       * <br><b>Since</b>: Maven 3.6.1
46       */
47      final String childSiteUrlInheritAppendPath;
48      /** Location of the xml element for this object. */
49      final InputLocation location;
50      /** Location of the xml element for the field id. */
51      final InputLocation idLocation;
52      /** Location of the xml element for the field name. */
53      final InputLocation nameLocation;
54      /** Location of the xml element for the field url. */
55      final InputLocation urlLocation;
56      /** Location of the xml element for the field childSiteUrlInheritAppendPath. */
57      final InputLocation childSiteUrlInheritAppendPathLocation;
58      /** Other locations */
59      final Map<Object, InputLocation> locations;
60  
61      /**
62        * Constructor for this class, package protected.
63        * @see Builder#build()
64        */
65      Site(
66          String id,
67          String name,
68          String url,
69          String childSiteUrlInheritAppendPath,
70          Map<Object, InputLocation> locations,
71          InputLocation location,
72          InputLocation idLocation,
73          InputLocation nameLocation,
74          InputLocation urlLocation,
75          InputLocation childSiteUrlInheritAppendPathLocation
76      )
77      {
78          this.id = id;
79          this.name = name;
80          this.url = url;
81          this.childSiteUrlInheritAppendPath = childSiteUrlInheritAppendPath;
82          this.locations = ImmutableCollections.copy( locations );
83          this.location = location;
84          this.idLocation = idLocation;
85          this.nameLocation = nameLocation;
86          this.urlLocation = urlLocation;
87          this.childSiteUrlInheritAppendPathLocation = childSiteUrlInheritAppendPathLocation;
88      }
89  
90      /**
91       * A unique identifier for a deployment location. This is used to match the
92       * site to configuration in the {@code settings.xml} file, for example.
93       *
94       * @return a {@code String}
95       */
96      public String getId()
97      {
98          return this.id;
99      }
100 
101     /**
102      * Human readable name of the deployment location.
103      *
104      * @return a {@code String}
105      */
106     public String getName()
107     {
108         return this.name;
109     }
110 
111     /**
112      * The url of the location where website is deployed, in the form {@code protocol://hostname/path}.
113      * <br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
114      * site's {@code child.site.url.inherit.append.path="false"}
115      *
116      * @return a {@code String}
117      */
118     public String getUrl()
119     {
120         return this.url;
121     }
122 
123     /**
124      * When children inherit from distribution management site url, append path or not? Note: While the type
125      * of this field is {@code String} for technical reasons, the semantic type is actually
126      * {@code Boolean}
127      * <br><b>Default value is</b>: {@code true}
128      * <br><b>Since</b>: Maven 3.6.1
129      *
130      * @return a {@code String}
131      */
132     public String getChildSiteUrlInheritAppendPath()
133     {
134         return this.childSiteUrlInheritAppendPath;
135     }
136 
137     /**
138      * Gets the location of the specified field in the input source.
139      */
140     public InputLocation getLocation( Object key )
141     {
142         if ( key instanceof String )
143         {
144             switch ( ( String ) key )
145             {
146                 case "":
147                     return location;
148                 case "id":
149                     return idLocation;
150                 case "name":
151                     return nameLocation;
152                 case "url":
153                     return urlLocation;
154                 case "childSiteUrlInheritAppendPath":
155                     return childSiteUrlInheritAppendPathLocation;
156             }
157         }
158         return locations != null ? locations.get( key ) : null;
159     }
160 
161     /**
162      * Creates a new builder with this object as the basis.
163      *
164      * @return a {@code Builder}
165      */
166     @Nonnull
167     public Builder with()
168     {
169         return newBuilder( this );
170     }
171     /**
172      * Creates a new {@code Site} instance using the specified id.
173      *
174      * @param id the new {@code String} to use
175      * @return a {@code Site} with the specified id
176      */
177     @Nonnull
178     public Site withId( String id )
179     {
180         return with().id( id ).build();
181     }
182     /**
183      * Creates a new {@code Site} instance using the specified name.
184      *
185      * @param name the new {@code String} to use
186      * @return a {@code Site} with the specified name
187      */
188     @Nonnull
189     public Site withName( String name )
190     {
191         return with().name( name ).build();
192     }
193     /**
194      * Creates a new {@code Site} instance using the specified url.
195      *
196      * @param url the new {@code String} to use
197      * @return a {@code Site} with the specified url
198      */
199     @Nonnull
200     public Site withUrl( String url )
201     {
202         return with().url( url ).build();
203     }
204     /**
205      * Creates a new {@code Site} instance using the specified childSiteUrlInheritAppendPath.
206      *
207      * @param childSiteUrlInheritAppendPath the new {@code String} to use
208      * @return a {@code Site} with the specified childSiteUrlInheritAppendPath
209      */
210     @Nonnull
211     public Site withChildSiteUrlInheritAppendPath( String childSiteUrlInheritAppendPath )
212     {
213         return with().childSiteUrlInheritAppendPath( childSiteUrlInheritAppendPath ).build();
214     }
215 
216     /**
217      * Creates a new {@code Site} instance.
218      * Equivalent to {@code newInstance( true )}.
219      * @see #newInstance(boolean)
220      *
221      * @return a new {@code Site}
222      */
223     @Nonnull
224     public static Site newInstance()
225     {
226         return newInstance( true );
227     }
228 
229     /**
230      * Creates a new {@code Site} instance using default values or not.
231      * Equivalent to {@code newBuilder( withDefaults ).build()}.
232      *
233      * @param withDefaults the boolean indicating whether default values should be used
234      * @return a new {@code Site}
235      */
236     @Nonnull
237     public static Site newInstance( boolean withDefaults )
238     {
239         return newBuilder( withDefaults ).build();
240     }
241 
242     /**
243      * Creates a new {@code Site} builder instance.
244      * Equivalent to {@code newBuilder( true )}.
245      * @see #newBuilder(boolean)
246      *
247      * @return a new {@code Builder}
248      */
249     @Nonnull
250     public static Builder newBuilder()
251     {
252         return newBuilder( true );
253     }
254 
255     /**
256      * Creates a new {@code Site} builder instance using default values or not.
257      *
258      * @param withDefaults the boolean indicating whether default values should be used
259      * @return a new {@code Builder}
260      */
261     @Nonnull
262     public static Builder newBuilder( boolean withDefaults )
263     {
264         return new Builder( withDefaults );
265     }
266 
267     /**
268      * Creates a new {@code Site} builder instance using the specified object as a basis.
269      * Equivalent to {@code newBuilder( from, false )}.
270      *
271      * @param from the {@code Site} instance to use as a basis
272      * @return a new {@code Builder}
273      */
274     @Nonnull
275     public static Builder newBuilder( Site from )
276     {
277         return newBuilder( from, false );
278     }
279 
280     /**
281      * Creates a new {@code Site} builder instance using the specified object as a basis.
282      *
283      * @param from the {@code Site} instance to use as a basis
284      * @param forceCopy the boolean indicating if a copy should be forced
285      * @return a new {@code Builder}
286      */
287     @Nonnull
288     public static Builder newBuilder( Site from, boolean forceCopy )
289     {
290         return new Builder( from, forceCopy );
291     }
292 
293     /**
294      * Builder class used to create Site instances.
295      * @see #with()
296      * @see #newBuilder()
297      */
298     @NotThreadSafe
299     public static class Builder
300     {
301         Site base;
302         String id;
303         String name;
304         String url;
305         String childSiteUrlInheritAppendPath;
306         Map<Object, InputLocation> locations;
307 
308         Builder( boolean withDefaults )
309         {
310             if ( withDefaults )
311             {
312             }
313         }
314 
315         Builder( Site base, boolean forceCopy )
316         {
317             if ( forceCopy )
318             {
319                 this.id = base.id;
320                 this.name = base.name;
321                 this.url = base.url;
322                 this.childSiteUrlInheritAppendPath = base.childSiteUrlInheritAppendPath;
323             }
324             else
325             {
326                 this.base = base;
327             }
328         }
329 
330         @Nonnull
331         public Builder id( String id )
332         {
333             this.id = id;
334             return this;
335         }
336 
337         @Nonnull
338         public Builder name( String name )
339         {
340             this.name = name;
341             return this;
342         }
343 
344         @Nonnull
345         public Builder url( String url )
346         {
347             this.url = url;
348             return this;
349         }
350 
351         @Nonnull
352         public Builder childSiteUrlInheritAppendPath( String childSiteUrlInheritAppendPath )
353         {
354             this.childSiteUrlInheritAppendPath = childSiteUrlInheritAppendPath;
355             return this;
356         }
357 
358 
359         @Nonnull
360         public Builder location( Object key, InputLocation location )
361         {
362             if ( location != null )
363             {
364                 if ( this.locations == null )
365                 {
366                     this.locations = new HashMap<>();
367                 }
368                 this.locations.put( key, location );
369             }
370             return this;
371         }
372 
373         @Nonnull
374         public Site build()
375         {
376             if ( base != null
377                     && ( id == null || id == base.id )
378                     && ( name == null || name == base.name )
379                     && ( url == null || url == base.url )
380                     && ( childSiteUrlInheritAppendPath == null || childSiteUrlInheritAppendPath == base.childSiteUrlInheritAppendPath )
381             )
382             {
383                 return base;
384             }
385             Map<Object, InputLocation> locations = null;
386             InputLocation location = null;
387             InputLocation idLocation = null;
388             InputLocation nameLocation = null;
389             InputLocation urlLocation = null;
390             InputLocation childSiteUrlInheritAppendPathLocation = null;
391             if ( this.locations != null )
392             {
393                 locations = this.locations;
394                 location = locations.remove( "" );
395                 idLocation = locations.remove( "id" );
396                 nameLocation = locations.remove( "name" );
397                 urlLocation = locations.remove( "url" );
398                 childSiteUrlInheritAppendPathLocation = locations.remove( "childSiteUrlInheritAppendPath" );
399             }
400             return new Site(
401                 id != null ? id : ( base != null ? base.id : null ),
402                 name != null ? name : ( base != null ? base.name : null ),
403                 url != null ? url : ( base != null ? base.url : null ),
404                 childSiteUrlInheritAppendPath != null ? childSiteUrlInheritAppendPath : ( base != null ? base.childSiteUrlInheritAppendPath : null ),
405                 locations != null ? locations : ( base != null ? base.locations : null ),
406                 location != null ? location : ( base != null ? base.location : null ),
407                 idLocation != null ? idLocation : ( base != null ? base.idLocation : null ),
408                 nameLocation != null ? nameLocation : ( base != null ? base.nameLocation : null ),
409                 urlLocation != null ? urlLocation : ( base != null ? base.urlLocation : null ),
410                 childSiteUrlInheritAppendPathLocation != null ? childSiteUrlInheritAppendPathLocation : ( base != null ? base.childSiteUrlInheritAppendPathLocation : null )
411             );
412         }
413     }
414 
415 
416             
417 
418     public boolean isChildSiteUrlInheritAppendPath()
419     {
420         return ( getChildSiteUrlInheritAppendPath() != null ) ? Boolean.parseBoolean( getChildSiteUrlInheritAppendPath() ) : true;
421     }
422 
423             
424           
425 }