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   * This is an activator which will detect an operating system's attributes in order to activate
20   * its profile.
21   */
22  @Experimental
23  @Generated @ThreadSafe @Immutable
24  public class ActivationOS
25      implements Serializable
26  {
27      /**
28       * The name of the OS to be used to activate a profile.
29       */
30      final String name;
31      /**
32       * The general family of the OS to be used to activate a
33       * profile (e.g. 'windows')
34       */
35      final String family;
36      /**
37       * The architecture of the OS to be used to activate a profile.
38       */
39      final String arch;
40      /**
41       * The version of the OS to be used to activate a profile.
42       */
43      final String version;
44  
45      /**
46        * Constructor for this class, package protected.
47        * @see Builder#build()
48        */
49      ActivationOS(
50          String name,
51          String family,
52          String arch,
53          String version
54      )
55      {
56          this.name = name;
57          this.family = family;
58          this.arch = arch;
59          this.version = version;
60      }
61  
62      /**
63       * The name of the OS to be used to activate a profile.
64       *
65       * @return a {@code String}
66       */
67      public String getName()
68      {
69          return this.name;
70      }
71  
72      /**
73       * The general family of the OS to be used to activate a
74       * profile (e.g. 'windows')
75       *
76       * @return a {@code String}
77       */
78      public String getFamily()
79      {
80          return this.family;
81      }
82  
83      /**
84       * The architecture of the OS to be used to activate a profile.
85       *
86       * @return a {@code String}
87       */
88      public String getArch()
89      {
90          return this.arch;
91      }
92  
93      /**
94       * The version of the OS to be used to activate a profile.
95       *
96       * @return a {@code String}
97       */
98      public String getVersion()
99      {
100         return this.version;
101     }
102 
103     /**
104      * Creates a new builder with this object as the basis.
105      *
106      * @return a {@code Builder}
107      */
108     @Nonnull
109     public Builder with()
110     {
111         return newBuilder( this );
112     }
113     /**
114      * Creates a new {@code ActivationOS} instance using the specified name.
115      *
116      * @param name the new {@code String} to use
117      * @return a {@code ActivationOS} with the specified name
118      */
119     @Nonnull
120     public ActivationOS withName( String name )
121     {
122         return with().name( name ).build();
123     }
124     /**
125      * Creates a new {@code ActivationOS} instance using the specified family.
126      *
127      * @param family the new {@code String} to use
128      * @return a {@code ActivationOS} with the specified family
129      */
130     @Nonnull
131     public ActivationOS withFamily( String family )
132     {
133         return with().family( family ).build();
134     }
135     /**
136      * Creates a new {@code ActivationOS} instance using the specified arch.
137      *
138      * @param arch the new {@code String} to use
139      * @return a {@code ActivationOS} with the specified arch
140      */
141     @Nonnull
142     public ActivationOS withArch( String arch )
143     {
144         return with().arch( arch ).build();
145     }
146     /**
147      * Creates a new {@code ActivationOS} instance using the specified version.
148      *
149      * @param version the new {@code String} to use
150      * @return a {@code ActivationOS} with the specified version
151      */
152     @Nonnull
153     public ActivationOS withVersion( String version )
154     {
155         return with().version( version ).build();
156     }
157 
158     /**
159      * Creates a new {@code ActivationOS} instance.
160      * Equivalent to {@code newInstance( true )}.
161      * @see #newInstance(boolean)
162      *
163      * @return a new {@code ActivationOS}
164      */
165     @Nonnull
166     public static ActivationOS newInstance()
167     {
168         return newInstance( true );
169     }
170 
171     /**
172      * Creates a new {@code ActivationOS} instance using default values or not.
173      * Equivalent to {@code newBuilder( withDefaults ).build()}.
174      *
175      * @param withDefaults the boolean indicating whether default values should be used
176      * @return a new {@code ActivationOS}
177      */
178     @Nonnull
179     public static ActivationOS newInstance( boolean withDefaults )
180     {
181         return newBuilder( withDefaults ).build();
182     }
183 
184     /**
185      * Creates a new {@code ActivationOS} builder instance.
186      * Equivalent to {@code newBuilder( true )}.
187      * @see #newBuilder(boolean)
188      *
189      * @return a new {@code Builder}
190      */
191     @Nonnull
192     public static Builder newBuilder()
193     {
194         return newBuilder( true );
195     }
196 
197     /**
198      * Creates a new {@code ActivationOS} builder instance using default values or not.
199      *
200      * @param withDefaults the boolean indicating whether default values should be used
201      * @return a new {@code Builder}
202      */
203     @Nonnull
204     public static Builder newBuilder( boolean withDefaults )
205     {
206         return new Builder( withDefaults );
207     }
208 
209     /**
210      * Creates a new {@code ActivationOS} builder instance using the specified object as a basis.
211      * Equivalent to {@code newBuilder( from, false )}.
212      *
213      * @param from the {@code ActivationOS} instance to use as a basis
214      * @return a new {@code Builder}
215      */
216     @Nonnull
217     public static Builder newBuilder( ActivationOS from )
218     {
219         return newBuilder( from, false );
220     }
221 
222     /**
223      * Creates a new {@code ActivationOS} builder instance using the specified object as a basis.
224      *
225      * @param from the {@code ActivationOS} instance to use as a basis
226      * @param forceCopy the boolean indicating if a copy should be forced
227      * @return a new {@code Builder}
228      */
229     @Nonnull
230     public static Builder newBuilder( ActivationOS from, boolean forceCopy )
231     {
232         return new Builder( from, forceCopy );
233     }
234 
235     /**
236      * Builder class used to create ActivationOS instances.
237      * @see #with()
238      * @see #newBuilder()
239      */
240     @NotThreadSafe
241     public static class Builder
242     {
243         ActivationOS base;
244         String name;
245         String family;
246         String arch;
247         String version;
248 
249         Builder( boolean withDefaults )
250         {
251             if ( withDefaults )
252             {
253             }
254         }
255 
256         Builder( ActivationOS base, boolean forceCopy )
257         {
258             if ( forceCopy )
259             {
260                 this.name = base.name;
261                 this.family = base.family;
262                 this.arch = base.arch;
263                 this.version = base.version;
264             }
265             else
266             {
267                 this.base = base;
268             }
269         }
270 
271         @Nonnull
272         public Builder name( String name )
273         {
274             this.name = name;
275             return this;
276         }
277 
278         @Nonnull
279         public Builder family( String family )
280         {
281             this.family = family;
282             return this;
283         }
284 
285         @Nonnull
286         public Builder arch( String arch )
287         {
288             this.arch = arch;
289             return this;
290         }
291 
292         @Nonnull
293         public Builder version( String version )
294         {
295             this.version = version;
296             return this;
297         }
298 
299 
300         @Nonnull
301         public ActivationOS build()
302         {
303             if ( base != null
304                     && ( name == null || name == base.name )
305                     && ( family == null || family == base.family )
306                     && ( arch == null || arch == base.arch )
307                     && ( version == null || version == base.version )
308             )
309             {
310                 return base;
311             }
312             return new ActivationOS(
313                 name != null ? name : ( base != null ? base.name : null ),
314                 family != null ? family : ( base != null ? base.family : null ),
315                 arch != null ? arch : ( base != null ? base.arch : null ),
316                 version != null ? version : ( base != null ? base.version : null )
317             );
318         }
319     }
320 
321 }