-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathProxyConfig.java
88 lines (76 loc) · 1.84 KB
/
ProxyConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// SPDX-FileCopyrightText: the secureCodeBox authors
//
// SPDX-License-Identifier: Apache-2.0
package io.securecodebox.persistence.defectdojo.http;
import lombok.Builder;
import lombok.Value;
/**
* Holds HTTP proxy configuration
* <p>
* This class is immutable by design and therefor thread safe. As defaults it does not use |{@code null} to prevent null
* pointer exceptions. It utilizes sane defaults (empty string or 0) to indicate a not set value. Also it introduces a
* null-object to indicate a not-existing configuration.
* </p>
*/
@Value
@Builder
public class ProxyConfig {
/**
* Null pattern object.
*/
public static final ProxyConfig NULL = ProxyConfig.builder().build();
private static final String DEFAULT_STRING = "";
private static final int DEFAULT_INT = 0;
/**
* Username to authenticate on a proxy.
* <p>
* Defaults to empty string.
* </p>
*/
@Builder.Default
String user = DEFAULT_STRING;
/**
* Password to authenticate on a proxy.
* <p>
* Defaults to empty string.
* </p>
*/
@Builder.Default
String password = DEFAULT_STRING;
/**
* Host name of the proxy.
* <p>
* Defaults to empty string.
* </p>
*/
@Builder.Default
String host = DEFAULT_STRING;
/**
* Port of the proxy.
* <p>
* Defaults to 0 (zero).
* </p>
*/
@Builder.Default
int port = DEFAULT_INT;
/**
* configuration is considered complete if all values are not default values
*
* @return {@code true} if all values are set else {@code false}
*/
public boolean isComplete() {
if (getUser().equals(DEFAULT_STRING)) {
return false;
}
if (getPassword().equals(DEFAULT_STRING)) {
return false;
}
if (getHost().equals(DEFAULT_STRING)) {
return false;
}
if (getPort() == DEFAULT_INT) {
return false;
}
return true;
}
}