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