23
23
* @author Eric Martin
24
24
*/
25
25
public class ApiConfiguration {
26
-
26
+
27
27
/**
28
28
* Default API URL
29
29
*/
30
30
private static final String DEFAULT_API_URL = "https://api.stackify.com" ;
31
-
31
+
32
32
/**
33
33
* API URL
34
34
*/
35
35
private final String apiUrl ;
36
-
36
+
37
37
/**
38
38
* API Key
39
39
*/
40
40
private final String apiKey ;
41
-
41
+
42
42
/**
43
43
* Application name
44
44
*/
45
45
private final String application ;
46
-
46
+
47
47
/**
48
48
* Environment
49
49
*/
50
50
private final String environment ;
51
-
51
+
52
52
/**
53
53
* Environment details
54
54
*/
@@ -93,11 +93,11 @@ public EnvironmentDetail getEnvDetail() {
93
93
* @param builder The Builder object that contains all of the values for initialization
94
94
*/
95
95
private ApiConfiguration (final Builder builder ) {
96
- this .apiUrl = builder .apiUrl ;
97
- this .apiKey = builder .apiKey ;
98
- this .application = builder .application ;
99
- this .environment = builder .environment ;
100
- this .envDetail = builder .envDetail ;
96
+ this .apiUrl = builder .apiUrl ;
97
+ this .apiKey = builder .apiKey ;
98
+ this .application = builder .application ;
99
+ this .environment = builder .environment ;
100
+ this .envDetail = builder .envDetail ;
101
101
}
102
102
103
103
/**
@@ -107,6 +107,19 @@ public static Builder newBuilder() {
107
107
return new Builder ();
108
108
}
109
109
110
+
111
+ /**
112
+ * @return a Builder object based on current instance
113
+ */
114
+ public Builder toBuilder () {
115
+ return newBuilder ()
116
+ .apiUrl (apiUrl )
117
+ .apiKey (apiKey )
118
+ .application (application )
119
+ .environment (environment )
120
+ .envDetail (envDetail );
121
+ }
122
+
110
123
/**
111
124
* ApiConfiguration.Builder separates the construction of a ApiConfiguration from its representation
112
125
*/
@@ -116,82 +129,82 @@ public static class Builder {
116
129
* The builder's apiUrl
117
130
*/
118
131
private String apiUrl ;
119
-
132
+
120
133
/**
121
134
* The builder's apiKey
122
135
*/
123
136
private String apiKey ;
124
-
137
+
125
138
/**
126
139
* The builder's application
127
140
*/
128
141
private String application ;
129
-
142
+
130
143
/**
131
144
* The builder's environment
132
145
*/
133
146
private String environment ;
134
-
147
+
135
148
/**
136
149
* The builder's envDetail
137
150
*/
138
151
private EnvironmentDetail envDetail ;
139
-
152
+
140
153
/**
141
154
* Sets the builder's apiUrl
142
155
* @param apiUrl The apiUrl to be set
143
156
* @return Reference to the current object
144
157
*/
145
158
public Builder apiUrl (final String apiUrl ) {
146
- this .apiUrl = apiUrl ;
147
- return this ;
159
+ this .apiUrl = apiUrl ;
160
+ return this ;
148
161
}
149
-
162
+
150
163
/**
151
164
* Sets the builder's apiKey
152
165
* @param apiKey The apiKey to be set
153
166
* @return Reference to the current object
154
167
*/
155
168
public Builder apiKey (final String apiKey ) {
156
- this .apiKey = apiKey ;
157
- return this ;
169
+ this .apiKey = apiKey ;
170
+ return this ;
158
171
}
159
-
172
+
160
173
/**
161
174
* Sets the builder's application
162
175
* @param application The application to be set
163
176
* @return Reference to the current object
164
177
*/
165
178
public Builder application (final String application ) {
166
- this .application = application ;
167
- return this ;
179
+ this .application = application ;
180
+ return this ;
168
181
}
169
-
182
+
170
183
/**
171
184
* Sets the builder's environment
172
185
* @param environment The environment to be set
173
186
* @return Reference to the current object
174
187
*/
175
188
public Builder environment (final String environment ) {
176
- this .environment = environment ;
177
- return this ;
189
+ this .environment = environment ;
190
+ return this ;
178
191
}
179
-
192
+
180
193
/**
181
194
* Sets the builder's envDetail
182
195
* @param envDetail The envDetail to be set
183
196
* @return Reference to the current object
184
197
*/
185
198
public Builder envDetail (final EnvironmentDetail envDetail ) {
186
- this .envDetail = envDetail ;
187
- return this ;
199
+ this .envDetail = envDetail ;
200
+ return this ;
188
201
}
189
-
202
+
190
203
/**
191
204
* @return A new object constructed from this builder
192
205
*/
193
206
public ApiConfiguration build () {
194
- return new ApiConfiguration (this );
207
+ return new ApiConfiguration (this );
195
208
}
196
209
}
197
210
@@ -201,13 +214,13 @@ public ApiConfiguration build() {
201
214
*/
202
215
@ Override
203
216
public String toString () {
204
- return Objects .toStringHelper (this )
205
- .omitNullValues ()
206
- .add ("apiUrl" , apiUrl )
207
- .add ("apiKey" , apiKey )
208
- .add ("application" , application )
209
- .add ("environment" , environment )
210
- .add ("envDetail" , envDetail )
211
- .toString ();
217
+ return Objects .toStringHelper (this )
218
+ .omitNullValues ()
219
+ .add ("apiUrl" , apiUrl )
220
+ .add ("apiKey" , apiKey )
221
+ .add ("application" , application )
222
+ .add ("environment" , environment )
223
+ .add ("envDetail" , envDetail )
224
+ .toString ();
212
225
}
213
226
}
0 commit comments