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.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 conditions within the build runtime environment which will trigger
20   * the automatic inclusion of the parent build profile.
21   */
22  @Experimental
23  @Generated @ThreadSafe @Immutable
24  public class Activation
25      implements Serializable
26  {
27      /**
28       * Flag specifying whether this profile is active as a default.
29       */
30      final boolean activeByDefault;
31      /**
32       * Specifies that this profile will be activated when a matching JDK is detected.
33       */
34      final String jdk;
35      /**
36       * Specifies that this profile will be activated when matching OS attributes are detected.
37       */
38      final ActivationOS os;
39      /**
40       * Specifies that this profile will be activated when this property is specified.
41       */
42      final ActivationProperty property;
43      /**
44       * Specifies that this profile will be activated based on existence of a file.
45       */
46      final ActivationFile file;
47  
48      /**
49        * Constructor for this class, package protected.
50        * @see Builder#build()
51        */
52      Activation(
53          boolean activeByDefault,
54          String jdk,
55          ActivationOS os,
56          ActivationProperty property,
57          ActivationFile file
58      )
59      {
60          this.activeByDefault = activeByDefault;
61          this.jdk = jdk;
62          this.os = os;
63          this.property = property;
64          this.file = file;
65      }
66  
67      /**
68       * Flag specifying whether this profile is active as a default.
69       *
70       * @return a {@code boolean}
71       */
72      public boolean isActiveByDefault()
73      {
74          return this.activeByDefault;
75      }
76  
77      /**
78       * Specifies that this profile will be activated when a matching JDK is detected.
79       *
80       * @return a {@code String}
81       */
82      public String getJdk()
83      {
84          return this.jdk;
85      }
86  
87      /**
88       * Specifies that this profile will be activated when matching OS attributes are detected.
89       *
90       * @return a {@code ActivationOS}
91       */
92      public ActivationOS getOs()
93      {
94          return this.os;
95      }
96  
97      /**
98       * Specifies that this profile will be activated when this property is specified.
99       *
100      * @return a {@code ActivationProperty}
101      */
102     public ActivationProperty getProperty()
103     {
104         return this.property;
105     }
106 
107     /**
108      * Specifies that this profile will be activated based on existence of a file.
109      *
110      * @return a {@code ActivationFile}
111      */
112     public ActivationFile getFile()
113     {
114         return this.file;
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 Activation} instance using the specified activeByDefault.
129      *
130      * @param activeByDefault the new {@code boolean} to use
131      * @return a {@code Activation} with the specified activeByDefault
132      */
133     @Nonnull
134     public Activation withActiveByDefault( boolean activeByDefault )
135     {
136         return with().activeByDefault( activeByDefault ).build();
137     }
138     /**
139      * Creates a new {@code Activation} instance using the specified jdk.
140      *
141      * @param jdk the new {@code String} to use
142      * @return a {@code Activation} with the specified jdk
143      */
144     @Nonnull
145     public Activation withJdk( String jdk )
146     {
147         return with().jdk( jdk ).build();
148     }
149     /**
150      * Creates a new {@code Activation} instance using the specified os.
151      *
152      * @param os the new {@code ActivationOS} to use
153      * @return a {@code Activation} with the specified os
154      */
155     @Nonnull
156     public Activation withOs( ActivationOS os )
157     {
158         return with().os( os ).build();
159     }
160     /**
161      * Creates a new {@code Activation} instance using the specified property.
162      *
163      * @param property the new {@code ActivationProperty} to use
164      * @return a {@code Activation} with the specified property
165      */
166     @Nonnull
167     public Activation withProperty( ActivationProperty property )
168     {
169         return with().property( property ).build();
170     }
171     /**
172      * Creates a new {@code Activation} instance using the specified file.
173      *
174      * @param file the new {@code ActivationFile} to use
175      * @return a {@code Activation} with the specified file
176      */
177     @Nonnull
178     public Activation withFile( ActivationFile file )
179     {
180         return with().file( file ).build();
181     }
182 
183     /**
184      * Creates a new {@code Activation} instance.
185      * Equivalent to {@code newInstance( true )}.
186      * @see #newInstance(boolean)
187      *
188      * @return a new {@code Activation}
189      */
190     @Nonnull
191     public static Activation newInstance()
192     {
193         return newInstance( true );
194     }
195 
196     /**
197      * Creates a new {@code Activation} 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 Activation}
202      */
203     @Nonnull
204     public static Activation newInstance( boolean withDefaults )
205     {
206         return newBuilder( withDefaults ).build();
207     }
208 
209     /**
210      * Creates a new {@code Activation} 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 Activation} 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 Activation} builder instance using the specified object as a basis.
236      * Equivalent to {@code newBuilder( from, false )}.
237      *
238      * @param from the {@code Activation} instance to use as a basis
239      * @return a new {@code Builder}
240      */
241     @Nonnull
242     public static Builder newBuilder( Activation from )
243     {
244         return newBuilder( from, false );
245     }
246 
247     /**
248      * Creates a new {@code Activation} builder instance using the specified object as a basis.
249      *
250      * @param from the {@code Activation} 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( Activation from, boolean forceCopy )
256     {
257         return new Builder( from, forceCopy );
258     }
259 
260     /**
261      * Builder class used to create Activation instances.
262      * @see #with()
263      * @see #newBuilder()
264      */
265     @NotThreadSafe
266     public static class Builder
267     {
268         Activation base;
269         Boolean activeByDefault;
270         String jdk;
271         ActivationOS os;
272         ActivationProperty property;
273         ActivationFile file;
274 
275         Builder( boolean withDefaults )
276         {
277             if ( withDefaults )
278             {
279                 this.activeByDefault = false;
280             }
281         }
282 
283         Builder( Activation base, boolean forceCopy )
284         {
285             if ( forceCopy )
286             {
287                 this.activeByDefault = base.activeByDefault;
288                 this.jdk = base.jdk;
289                 this.os = base.os;
290                 this.property = base.property;
291                 this.file = base.file;
292             }
293             else
294             {
295                 this.base = base;
296             }
297         }
298 
299         @Nonnull
300         public Builder activeByDefault( boolean activeByDefault )
301         {
302             this.activeByDefault = activeByDefault;
303             return this;
304         }
305 
306         @Nonnull
307         public Builder jdk( String jdk )
308         {
309             this.jdk = jdk;
310             return this;
311         }
312 
313         @Nonnull
314         public Builder os( ActivationOS os )
315         {
316             this.os = os;
317             return this;
318         }
319 
320         @Nonnull
321         public Builder property( ActivationProperty property )
322         {
323             this.property = property;
324             return this;
325         }
326 
327         @Nonnull
328         public Builder file( ActivationFile file )
329         {
330             this.file = file;
331             return this;
332         }
333 
334 
335         @Nonnull
336         public Activation build()
337         {
338             if ( base != null
339                     && ( activeByDefault == null || activeByDefault == base.activeByDefault )
340                     && ( jdk == null || jdk == base.jdk )
341                     && ( os == null || os == base.os )
342                     && ( property == null || property == base.property )
343                     && ( file == null || file == base.file )
344             )
345             {
346                 return base;
347             }
348             return new Activation(
349                 activeByDefault != null ? activeByDefault : ( base != null ? base.activeByDefault : false ),
350                 jdk != null ? jdk : ( base != null ? base.jdk : null ),
351                 os != null ? os : ( base != null ? base.os : null ),
352                 property != null ? property : ( base != null ? base.property : null ),
353                 file != null ? file : ( base != null ? base.file : null )
354             );
355         }
356     }
357 
358 }