Skip to content

Commit 1ae6283

Browse files
committed
Merge pull request #2 from blackopseng3/master
multiple applications support
2 parents ad5e226 + d0f8768 commit 1ae6283

File tree

4 files changed

+279
-148
lines changed

4 files changed

+279
-148
lines changed

src/main/java/com/stackify/api/common/ApiConfiguration.java

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,32 @@
2323
* @author Eric Martin
2424
*/
2525
public class ApiConfiguration {
26-
26+
2727
/**
2828
* Default API URL
2929
*/
3030
private static final String DEFAULT_API_URL = "https://api.stackify.com";
31-
31+
3232
/**
3333
* API URL
3434
*/
3535
private final String apiUrl;
36-
36+
3737
/**
3838
* API Key
3939
*/
4040
private final String apiKey;
41-
41+
4242
/**
4343
* Application name
4444
*/
4545
private final String application;
46-
46+
4747
/**
4848
* Environment
4949
*/
5050
private final String environment;
51-
51+
5252
/**
5353
* Environment details
5454
*/
@@ -93,11 +93,11 @@ public EnvironmentDetail getEnvDetail() {
9393
* @param builder The Builder object that contains all of the values for initialization
9494
*/
9595
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;
101101
}
102102

103103
/**
@@ -107,6 +107,19 @@ public static Builder newBuilder() {
107107
return new Builder();
108108
}
109109

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+
110123
/**
111124
* ApiConfiguration.Builder separates the construction of a ApiConfiguration from its representation
112125
*/
@@ -116,82 +129,82 @@ public static class Builder {
116129
* The builder's apiUrl
117130
*/
118131
private String apiUrl;
119-
132+
120133
/**
121134
* The builder's apiKey
122135
*/
123136
private String apiKey;
124-
137+
125138
/**
126139
* The builder's application
127140
*/
128141
private String application;
129-
142+
130143
/**
131144
* The builder's environment
132145
*/
133146
private String environment;
134-
147+
135148
/**
136149
* The builder's envDetail
137150
*/
138151
private EnvironmentDetail envDetail;
139-
152+
140153
/**
141154
* Sets the builder's apiUrl
142155
* @param apiUrl The apiUrl to be set
143156
* @return Reference to the current object
144157
*/
145158
public Builder apiUrl(final String apiUrl) {
146-
this.apiUrl = apiUrl;
147-
return this;
159+
this.apiUrl = apiUrl;
160+
return this;
148161
}
149-
162+
150163
/**
151164
* Sets the builder's apiKey
152165
* @param apiKey The apiKey to be set
153166
* @return Reference to the current object
154167
*/
155168
public Builder apiKey(final String apiKey) {
156-
this.apiKey = apiKey;
157-
return this;
169+
this.apiKey = apiKey;
170+
return this;
158171
}
159-
172+
160173
/**
161174
* Sets the builder's application
162175
* @param application The application to be set
163176
* @return Reference to the current object
164177
*/
165178
public Builder application(final String application) {
166-
this.application = application;
167-
return this;
179+
this.application = application;
180+
return this;
168181
}
169-
182+
170183
/**
171184
* Sets the builder's environment
172185
* @param environment The environment to be set
173186
* @return Reference to the current object
174187
*/
175188
public Builder environment(final String environment) {
176-
this.environment = environment;
177-
return this;
189+
this.environment = environment;
190+
return this;
178191
}
179-
192+
180193
/**
181194
* Sets the builder's envDetail
182195
* @param envDetail The envDetail to be set
183196
* @return Reference to the current object
184197
*/
185198
public Builder envDetail(final EnvironmentDetail envDetail) {
186-
this.envDetail = envDetail;
187-
return this;
199+
this.envDetail = envDetail;
200+
return this;
188201
}
189-
202+
190203
/**
191204
* @return A new object constructed from this builder
192205
*/
193206
public ApiConfiguration build() {
194-
return new ApiConfiguration(this);
207+
return new ApiConfiguration(this);
195208
}
196209
}
197210

@@ -201,13 +214,13 @@ public ApiConfiguration build() {
201214
*/
202215
@Override
203216
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();
212225
}
213226
}

0 commit comments

Comments
 (0)