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