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