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