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