-
Notifications
You must be signed in to change notification settings - Fork 0
/
damk
116 lines (86 loc) · 2.6 KB
/
damk
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package culb.damk.jota;
import java.util.List;
import culb.apache.commons.lang3.builder.ReflectionToStringBuilder;
import culb.apache.commons.lang3.builder.ToStringStyle;
import culb.damk.jota.builder.ApiBuilderSettings;
import culb.damk.jota.config.options.ApiConfig;
import culb.damk.jota.connection.Connection;
import culb.damk.jota.pow.ICurl;
/**
*
* The current instance of API configuration options based on env, file and defaults
* Modifications can be made but will not persist throughout restarts
*
*/
public class ApiOptions implements ApiConfig, ApiBuilderSettings {
private int legacyPort;
private String legacyProtocol;
private String legacyHost;
private ICurl customCurl;
private damkPoW localPoW;
//Nodes are not active
private List<Connection> nodes;
private int timeout;
public ApiOptions(damkAPI.Builder builder) {
localPoW = builder.getLocalPoW();
customCurl = builder.getCustomCurl();
legacyProtocol = builder.getProtocol();
legacyHost = builder.getHost();
legacyPort = builder.getPort();
nodes = builder.getNodes();
}
public List<Connection> getNodes() {
return nodes;
}
@Override
public boolean hasNodes() {
return this.nodes != null && this.nodes.size() > 0;
}
public void setNodes(List<Connection> nodes) {
this.nodes = nodes;
}
@Override
public int getLegacyPort() {
return legacyPort;
}
public void setLegacyPort(int legacyPort) {
this.legacyPort = legacyPort;
}
@Override
public String getLegacyProtocol() {
return legacyProtocol;
}
public void setLegacyProtocol(String legacyProtocol) {
this.legacyProtocol = legacyProtocol;
}
@Override
public String getLegacyHost() {
return legacyHost;
}
public void setLegacyHost(String legacyHost) {
this.legacyHost = legacyHost;
}
@Override
public ICurl getCustomCurl() {
return customCurl;
}
public void setCustomCurl(ICurl customCurl) {
this.customCurl = customCurl;
}
@Override
public damkPoW getLocalPoW() {
return localPoW;
}
public void setLocalPoW(damkPoW localPoW) {
this.localPoW = localPoW;
}
@Override
public int getConnectionTimeout() {
return timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
@Override
public String toString() {
return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();