View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //   Generated by Maven, any modifications will be overwritten.
3   // ==============================================================
4   package org.apache.maven.api.settings;
5   
6   import java.io.Serializable;
7   import java.util.ArrayList;
8   import java.util.Collection;
9   import java.util.Collections;
10  import java.util.HashMap;
11  import java.util.List;
12  import java.util.Map;
13  import org.apache.maven.api.annotations.Experimental;
14  import org.apache.maven.api.annotations.Generated;
15  import org.apache.maven.api.annotations.Immutable;
16  import org.apache.maven.api.annotations.Nonnull;
17  import org.apache.maven.api.annotations.NotThreadSafe;
18  import org.apache.maven.api.annotations.ThreadSafe;
19  
20  /**
21   * Modifications to the build process which is keyed on some
22   * sort of environmental parameter.
23   */
24  @Experimental
25  @Generated @ThreadSafe @Immutable
26  public class Profile
27      extends IdentifiableBase
28      implements Serializable
29  {
30      /**
31       * The conditional logic which will automatically
32       * trigger the inclusion of this profile.
33       */
34      final Activation activation;
35      /**
36       * Extended configuration specific to this profile goes here.
37       * Contents take the form of
38       * <code>&lt;property.name&gt;property.value&lt;/property.name&gt;</code>
39       */
40      final Map<String, String> properties;
41      /**
42       * The lists of the remote repositories.
43       */
44      final List<Repository> repositories;
45      /**
46       * The lists of the remote repositories for discovering plugins.
47       */
48      final List<Repository> pluginRepositories;
49  
50      /**
51        * Constructor for this class, package protected.
52        * @see Builder#build()
53        */
54      Profile(
55          String id,
56          Activation activation,
57          Map<String, String> properties,
58          Collection<Repository> repositories,
59          Collection<Repository> pluginRepositories
60      )
61      {
62          super(
63              id
64          );
65          this.activation = activation;
66          this.properties = ImmutableCollections.copy( properties );
67          this.repositories = ImmutableCollections.copy( repositories );
68          this.pluginRepositories = ImmutableCollections.copy( pluginRepositories );
69      }
70  
71      /**
72       * The conditional logic which will automatically
73       * trigger the inclusion of this profile.
74       *
75       * @return a {@code Activation}
76       */
77      public Activation getActivation()
78      {
79          return this.activation;
80      }
81  
82      /**
83       * Extended configuration specific to this profile goes here.
84       * Contents take the form of
85       * <code>&lt;property.name&gt;property.value&lt;/property.name&gt;</code>
86       *
87       * @return a {@code Map<String, String>}
88       */
89      @Nonnull
90      public Map<String, String> getProperties()
91      {
92          return this.properties;
93      }
94  
95      /**
96       * The lists of the remote repositories.
97       *
98       * @return a {@code List<Repository>}
99       */
100     @Nonnull
101     public List<Repository> getRepositories()
102     {
103         return this.repositories;
104     }
105 
106     /**
107      * The lists of the remote repositories for discovering plugins.
108      *
109      * @return a {@code List<Repository>}
110      */
111     @Nonnull
112     public List<Repository> getPluginRepositories()
113     {
114         return this.pluginRepositories;
115     }
116 
117     /**
118      * Creates a new builder with this object as the basis.
119      *
120      * @return a {@code Builder}
121      */
122     @Nonnull
123     public Builder with()
124     {
125         return newBuilder( this );
126     }
127     /**
128      * Creates a new {@code Profile} instance using the specified id.
129      *
130      * @param id the new {@code String} to use
131      * @return a {@code Profile} with the specified id
132      */
133     @Nonnull
134     public Profile withId( String id )
135     {
136         return with().id( id ).build();
137     }
138     /**
139      * Creates a new {@code Profile} instance using the specified activation.
140      *
141      * @param activation the new {@code Activation} to use
142      * @return a {@code Profile} with the specified activation
143      */
144     @Nonnull
145     public Profile withActivation( Activation activation )
146     {
147         return with().activation( activation ).build();
148     }
149     /**
150      * Creates a new {@code Profile} instance using the specified properties.
151      *
152      * @param properties the new {@code Map<String, String>} to use
153      * @return a {@code Profile} with the specified properties
154      */
155     @Nonnull
156     public Profile withProperties( Map<String, String> properties )
157     {
158         return with().properties( properties ).build();
159     }
160     /**
161      * Creates a new {@code Profile} instance using the specified repositories.
162      *
163      * @param repositories the new {@code Collection<Repository>} to use
164      * @return a {@code Profile} with the specified repositories
165      */
166     @Nonnull
167     public Profile withRepositories( Collection<Repository> repositories )
168     {
169         return with().repositories( repositories ).build();
170     }
171     /**
172      * Creates a new {@code Profile} instance using the specified pluginRepositories.
173      *
174      * @param pluginRepositories the new {@code Collection<Repository>} to use
175      * @return a {@code Profile} with the specified pluginRepositories
176      */
177     @Nonnull
178     public Profile withPluginRepositories( Collection<Repository> pluginRepositories )
179     {
180         return with().pluginRepositories( pluginRepositories ).build();
181     }
182 
183     /**
184      * Creates a new {@code Profile} instance.
185      * Equivalent to {@code newInstance( true )}.
186      * @see #newInstance(boolean)
187      *
188      * @return a new {@code Profile}
189      */
190     @Nonnull
191     public static Profile newInstance()
192     {
193         return newInstance( true );
194     }
195 
196     /**
197      * Creates a new {@code Profile} instance using default values or not.
198      * Equivalent to {@code newBuilder( withDefaults ).build()}.
199      *
200      * @param withDefaults the boolean indicating whether default values should be used
201      * @return a new {@code Profile}
202      */
203     @Nonnull
204     public static Profile newInstance( boolean withDefaults )
205     {
206         return newBuilder( withDefaults ).build();
207     }
208 
209     /**
210      * Creates a new {@code Profile} builder instance.
211      * Equivalent to {@code newBuilder( true )}.
212      * @see #newBuilder(boolean)
213      *
214      * @return a new {@code Builder}
215      */
216     @Nonnull
217     public static Builder newBuilder()
218     {
219         return newBuilder( true );
220     }
221 
222     /**
223      * Creates a new {@code Profile} builder instance using default values or not.
224      *
225      * @param withDefaults the boolean indicating whether default values should be used
226      * @return a new {@code Builder}
227      */
228     @Nonnull
229     public static Builder newBuilder( boolean withDefaults )
230     {
231         return new Builder( withDefaults );
232     }
233 
234     /**
235      * Creates a new {@code Profile} builder instance using the specified object as a basis.
236      * Equivalent to {@code newBuilder( from, false )}.
237      *
238      * @param from the {@code Profile} instance to use as a basis
239      * @return a new {@code Builder}
240      */
241     @Nonnull
242     public static Builder newBuilder( Profile from )
243     {
244         return newBuilder( from, false );
245     }
246 
247     /**
248      * Creates a new {@code Profile} builder instance using the specified object as a basis.
249      *
250      * @param from the {@code Profile} instance to use as a basis
251      * @param forceCopy the boolean indicating if a copy should be forced
252      * @return a new {@code Builder}
253      */
254     @Nonnull
255     public static Builder newBuilder( Profile from, boolean forceCopy )
256     {
257         return new Builder( from, forceCopy );
258     }
259 
260     /**
261      * Builder class used to create Profile instances.
262      * @see #with()
263      * @see #newBuilder()
264      */
265     @NotThreadSafe
266     public static class Builder
267         extends IdentifiableBase.Builder
268     {
269         Profile base;
270         Activation activation;
271         Map<String, String> properties;
272         Collection<Repository> repositories;
273         Collection<Repository> pluginRepositories;
274 
275         Builder( boolean withDefaults )
276         {
277             super( withDefaults );
278             if ( withDefaults )
279             {
280             }
281         }
282 
283         Builder( Profile base, boolean forceCopy )
284         {
285             super( base, forceCopy );
286             if ( forceCopy )
287             {
288                 this.activation = base.activation;
289                 this.properties = base.properties;
290                 this.repositories = base.repositories;
291                 this.pluginRepositories = base.pluginRepositories;
292             }
293             else
294             {
295                 this.base = base;
296             }
297         }
298 
299         @Nonnull
300         public Builder id( String id )
301         {
302             this.id = id;
303             return this;
304         }
305 
306         @Nonnull
307         public Builder activation( Activation activation )
308         {
309             this.activation = activation;
310             return this;
311         }
312 
313         @Nonnull
314         public Builder properties( Map<String, String> properties )
315         {
316             this.properties = properties;
317             return this;
318         }
319 
320         @Nonnull
321         public Builder repositories( Collection<Repository> repositories )
322         {
323             this.repositories = repositories;
324             return this;
325         }
326 
327         @Nonnull
328         public Builder pluginRepositories( Collection<Repository> pluginRepositories )
329         {
330             this.pluginRepositories = pluginRepositories;
331             return this;
332         }
333 
334 
335         @Nonnull
336         public Profile build()
337         {
338             if ( base != null
339                     && ( id == null || id == base.id )
340                     && ( activation == null || activation == base.activation )
341                     && ( properties == null || properties == base.properties )
342                     && ( repositories == null || repositories == base.repositories )
343                     && ( pluginRepositories == null || pluginRepositories == base.pluginRepositories )
344             )
345             {
346                 return base;
347             }
348             return new Profile(
349                 id != null ? id : ( base != null ? base.id : null ),
350                 activation != null ? activation : ( base != null ? base.activation : null ),
351                 properties != null ? properties : ( base != null ? base.properties : null ),
352                 repositories != null ? repositories : ( base != null ? base.repositories : null ),
353                 pluginRepositories != null ? pluginRepositories : ( base != null ? base.pluginRepositories : null )
354             );
355         }
356     }
357 
358 }