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  import org.apache.maven.api.xml.XmlNode;
18  
19  /**
20   * The <code>&lt;server&gt;</code> element contains informations required to a server settings.
21   */
22  @Experimental
23  @Generated @ThreadSafe @Immutable
24  public class Server
25      extends IdentifiableBase
26      implements Serializable
27  {
28      /**
29       * The username used to authenticate.
30       */
31      final String username;
32      /**
33       * The password used in conjunction with the username to authenticate.
34       */
35      final String password;
36      /**
37       * The private key location used to authenticate.
38       */
39      final String privateKey;
40      /**
41       * The passphrase used in conjunction with the privateKey to authenticate.
42       */
43      final String passphrase;
44      /**
45       * The permissions for files when they are created.
46       */
47      final String filePermissions;
48      /**
49       * The permissions for directories when they are created.
50       */
51      final String directoryPermissions;
52      /**
53       * Extra configuration for the transport layer.
54       */
55      final XmlNode configuration;
56  
57      /**
58        * Constructor for this class, package protected.
59        * @see Builder#build()
60        */
61      Server(
62          String id,
63          String username,
64          String password,
65          String privateKey,
66          String passphrase,
67          String filePermissions,
68          String directoryPermissions,
69          XmlNode configuration
70      )
71      {
72          super(
73              id
74          );
75          this.username = username;
76          this.password = password;
77          this.privateKey = privateKey;
78          this.passphrase = passphrase;
79          this.filePermissions = filePermissions;
80          this.directoryPermissions = directoryPermissions;
81          this.configuration = configuration;
82      }
83  
84      /**
85       * The username used to authenticate.
86       *
87       * @return a {@code String}
88       */
89      public String getUsername()
90      {
91          return this.username;
92      }
93  
94      /**
95       * The password used in conjunction with the username to authenticate.
96       *
97       * @return a {@code String}
98       */
99      public String getPassword()
100     {
101         return this.password;
102     }
103 
104     /**
105      * The private key location used to authenticate.
106      *
107      * @return a {@code String}
108      */
109     public String getPrivateKey()
110     {
111         return this.privateKey;
112     }
113 
114     /**
115      * The passphrase used in conjunction with the privateKey to authenticate.
116      *
117      * @return a {@code String}
118      */
119     public String getPassphrase()
120     {
121         return this.passphrase;
122     }
123 
124     /**
125      * The permissions for files when they are created.
126      *
127      * @return a {@code String}
128      */
129     public String getFilePermissions()
130     {
131         return this.filePermissions;
132     }
133 
134     /**
135      * The permissions for directories when they are created.
136      *
137      * @return a {@code String}
138      */
139     public String getDirectoryPermissions()
140     {
141         return this.directoryPermissions;
142     }
143 
144     /**
145      * Extra configuration for the transport layer.
146      *
147      * @return a {@code XmlNode}
148      */
149     public XmlNode getConfiguration()
150     {
151         return this.configuration;
152     }
153 
154     /**
155      * Creates a new builder with this object as the basis.
156      *
157      * @return a {@code Builder}
158      */
159     @Nonnull
160     public Builder with()
161     {
162         return newBuilder( this );
163     }
164     /**
165      * Creates a new {@code Server} instance using the specified id.
166      *
167      * @param id the new {@code String} to use
168      * @return a {@code Server} with the specified id
169      */
170     @Nonnull
171     public Server withId( String id )
172     {
173         return with().id( id ).build();
174     }
175     /**
176      * Creates a new {@code Server} instance using the specified username.
177      *
178      * @param username the new {@code String} to use
179      * @return a {@code Server} with the specified username
180      */
181     @Nonnull
182     public Server withUsername( String username )
183     {
184         return with().username( username ).build();
185     }
186     /**
187      * Creates a new {@code Server} instance using the specified password.
188      *
189      * @param password the new {@code String} to use
190      * @return a {@code Server} with the specified password
191      */
192     @Nonnull
193     public Server withPassword( String password )
194     {
195         return with().password( password ).build();
196     }
197     /**
198      * Creates a new {@code Server} instance using the specified privateKey.
199      *
200      * @param privateKey the new {@code String} to use
201      * @return a {@code Server} with the specified privateKey
202      */
203     @Nonnull
204     public Server withPrivateKey( String privateKey )
205     {
206         return with().privateKey( privateKey ).build();
207     }
208     /**
209      * Creates a new {@code Server} instance using the specified passphrase.
210      *
211      * @param passphrase the new {@code String} to use
212      * @return a {@code Server} with the specified passphrase
213      */
214     @Nonnull
215     public Server withPassphrase( String passphrase )
216     {
217         return with().passphrase( passphrase ).build();
218     }
219     /**
220      * Creates a new {@code Server} instance using the specified filePermissions.
221      *
222      * @param filePermissions the new {@code String} to use
223      * @return a {@code Server} with the specified filePermissions
224      */
225     @Nonnull
226     public Server withFilePermissions( String filePermissions )
227     {
228         return with().filePermissions( filePermissions ).build();
229     }
230     /**
231      * Creates a new {@code Server} instance using the specified directoryPermissions.
232      *
233      * @param directoryPermissions the new {@code String} to use
234      * @return a {@code Server} with the specified directoryPermissions
235      */
236     @Nonnull
237     public Server withDirectoryPermissions( String directoryPermissions )
238     {
239         return with().directoryPermissions( directoryPermissions ).build();
240     }
241     /**
242      * Creates a new {@code Server} instance using the specified configuration.
243      *
244      * @param configuration the new {@code XmlNode} to use
245      * @return a {@code Server} with the specified configuration
246      */
247     @Nonnull
248     public Server withConfiguration( XmlNode configuration )
249     {
250         return with().configuration( configuration ).build();
251     }
252 
253     /**
254      * Creates a new {@code Server} instance.
255      * Equivalent to {@code newInstance( true )}.
256      * @see #newInstance(boolean)
257      *
258      * @return a new {@code Server}
259      */
260     @Nonnull
261     public static Server newInstance()
262     {
263         return newInstance( true );
264     }
265 
266     /**
267      * Creates a new {@code Server} instance using default values or not.
268      * Equivalent to {@code newBuilder( withDefaults ).build()}.
269      *
270      * @param withDefaults the boolean indicating whether default values should be used
271      * @return a new {@code Server}
272      */
273     @Nonnull
274     public static Server newInstance( boolean withDefaults )
275     {
276         return newBuilder( withDefaults ).build();
277     }
278 
279     /**
280      * Creates a new {@code Server} builder instance.
281      * Equivalent to {@code newBuilder( true )}.
282      * @see #newBuilder(boolean)
283      *
284      * @return a new {@code Builder}
285      */
286     @Nonnull
287     public static Builder newBuilder()
288     {
289         return newBuilder( true );
290     }
291 
292     /**
293      * Creates a new {@code Server} builder instance using default values or not.
294      *
295      * @param withDefaults the boolean indicating whether default values should be used
296      * @return a new {@code Builder}
297      */
298     @Nonnull
299     public static Builder newBuilder( boolean withDefaults )
300     {
301         return new Builder( withDefaults );
302     }
303 
304     /**
305      * Creates a new {@code Server} builder instance using the specified object as a basis.
306      * Equivalent to {@code newBuilder( from, false )}.
307      *
308      * @param from the {@code Server} instance to use as a basis
309      * @return a new {@code Builder}
310      */
311     @Nonnull
312     public static Builder newBuilder( Server from )
313     {
314         return newBuilder( from, false );
315     }
316 
317     /**
318      * Creates a new {@code Server} builder instance using the specified object as a basis.
319      *
320      * @param from the {@code Server} instance to use as a basis
321      * @param forceCopy the boolean indicating if a copy should be forced
322      * @return a new {@code Builder}
323      */
324     @Nonnull
325     public static Builder newBuilder( Server from, boolean forceCopy )
326     {
327         return new Builder( from, forceCopy );
328     }
329 
330     /**
331      * Builder class used to create Server instances.
332      * @see #with()
333      * @see #newBuilder()
334      */
335     @NotThreadSafe
336     public static class Builder
337         extends IdentifiableBase.Builder
338     {
339         Server base;
340         String username;
341         String password;
342         String privateKey;
343         String passphrase;
344         String filePermissions;
345         String directoryPermissions;
346         XmlNode configuration;
347 
348         Builder( boolean withDefaults )
349         {
350             super( withDefaults );
351             if ( withDefaults )
352             {
353             }
354         }
355 
356         Builder( Server base, boolean forceCopy )
357         {
358             super( base, forceCopy );
359             if ( forceCopy )
360             {
361                 this.username = base.username;
362                 this.password = base.password;
363                 this.privateKey = base.privateKey;
364                 this.passphrase = base.passphrase;
365                 this.filePermissions = base.filePermissions;
366                 this.directoryPermissions = base.directoryPermissions;
367                 this.configuration = base.configuration;
368             }
369             else
370             {
371                 this.base = base;
372             }
373         }
374 
375         @Nonnull
376         public Builder id( String id )
377         {
378             this.id = id;
379             return this;
380         }
381 
382         @Nonnull
383         public Builder username( String username )
384         {
385             this.username = username;
386             return this;
387         }
388 
389         @Nonnull
390         public Builder password( String password )
391         {
392             this.password = password;
393             return this;
394         }
395 
396         @Nonnull
397         public Builder privateKey( String privateKey )
398         {
399             this.privateKey = privateKey;
400             return this;
401         }
402 
403         @Nonnull
404         public Builder passphrase( String passphrase )
405         {
406             this.passphrase = passphrase;
407             return this;
408         }
409 
410         @Nonnull
411         public Builder filePermissions( String filePermissions )
412         {
413             this.filePermissions = filePermissions;
414             return this;
415         }
416 
417         @Nonnull
418         public Builder directoryPermissions( String directoryPermissions )
419         {
420             this.directoryPermissions = directoryPermissions;
421             return this;
422         }
423 
424         @Nonnull
425         public Builder configuration( XmlNode configuration )
426         {
427             this.configuration = configuration;
428             return this;
429         }
430 
431 
432         @Nonnull
433         public Server build()
434         {
435             if ( base != null
436                     && ( id == null || id == base.id )
437                     && ( username == null || username == base.username )
438                     && ( password == null || password == base.password )
439                     && ( privateKey == null || privateKey == base.privateKey )
440                     && ( passphrase == null || passphrase == base.passphrase )
441                     && ( filePermissions == null || filePermissions == base.filePermissions )
442                     && ( directoryPermissions == null || directoryPermissions == base.directoryPermissions )
443                     && ( configuration == null || configuration == base.configuration )
444             )
445             {
446                 return base;
447             }
448             return new Server(
449                 id != null ? id : ( base != null ? base.id : null ),
450                 username != null ? username : ( base != null ? base.username : null ),
451                 password != null ? password : ( base != null ? base.password : null ),
452                 privateKey != null ? privateKey : ( base != null ? base.privateKey : null ),
453                 passphrase != null ? passphrase : ( base != null ? base.passphrase : null ),
454                 filePermissions != null ? filePermissions : ( base != null ? base.filePermissions : null ),
455                 directoryPermissions != null ? directoryPermissions : ( base != null ? base.directoryPermissions : null ),
456                 configuration != null ? configuration : ( base != null ? base.configuration : null )
457             );
458         }
459     }
460 
461 }