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