11package com .github .switcherapi .client ;
22
3+ import com .github .switcherapi .client .model .ContextKey ;
34import org .apache .commons .lang3 .StringUtils ;
45
56public class ContextBuilder {
@@ -52,7 +53,7 @@ SwitcherProperties build() {
5253 * @return ContextBuilder
5354 */
5455 public ContextBuilder contextLocation (String contextLocation ) {
55- properties .setContextLocation ( contextLocation );
56+ properties .setValue ( ContextKey . CONTEXT_LOCATION , contextLocation );
5657 return this ;
5758 }
5859
@@ -61,7 +62,7 @@ public ContextBuilder contextLocation(String contextLocation) {
6162 * @return ContextBuilder
6263 */
6364 public ContextBuilder url (String url ) {
64- properties .setUrl ( url );
65+ properties .setValue ( ContextKey . URL , url );
6566 return this ;
6667 }
6768
@@ -70,7 +71,7 @@ public ContextBuilder url(String url) {
7071 * @return ContextBuilder
7172 */
7273 public ContextBuilder apiKey (String apiKey ) {
73- properties .setApiKey ( apiKey );
74+ properties .setValue ( ContextKey . APIKEY , apiKey );
7475 return this ;
7576 }
7677
@@ -79,7 +80,7 @@ public ContextBuilder apiKey(String apiKey) {
7980 * @return ContextBuilder
8081 */
8182 public ContextBuilder domain (String domain ) {
82- properties .setDomain ( domain );
83+ properties .setValue ( ContextKey . DOMAIN , domain );
8384 return this ;
8485 }
8586
@@ -88,7 +89,7 @@ public ContextBuilder domain(String domain) {
8889 * @return ContextBuilder
8990 */
9091 public ContextBuilder component (String component ) {
91- properties .setComponent ( component );
92+ properties .setValue ( ContextKey . COMPONENT , component );
9293 return this ;
9394 }
9495
@@ -97,7 +98,7 @@ public ContextBuilder component(String component) {
9798 * @return ContextBuilder
9899 */
99100 public ContextBuilder environment (String environment ) {
100- properties .setEnvironment ( environment );
101+ properties .setValue ( ContextKey . ENVIRONMENT , properties . getEnvironmentOrDefault ( environment ) );
101102 return this ;
102103 }
103104
@@ -106,7 +107,7 @@ public ContextBuilder environment(String environment) {
106107 * @return ContextBuilder
107108 */
108109 public ContextBuilder snapshotLocation (String snapshotLocation ) {
109- properties .setSnapshotLocation ( snapshotLocation );
110+ properties .setValue ( ContextKey . SNAPSHOT_LOCATION , snapshotLocation );
110111 return this ;
111112 }
112113
@@ -115,10 +116,10 @@ public ContextBuilder snapshotLocation(String snapshotLocation) {
115116 * @return ContextBuilder
116117 */
117118 public ContextBuilder snapshotAutoUpdateInterval (String snapshotAutoUpdateInterval ) {
118- properties .setSnapshotAutoUpdateInterval ( snapshotAutoUpdateInterval );
119+ properties .setValue ( ContextKey . SNAPSHOT_AUTO_UPDATE_INTERVAL , snapshotAutoUpdateInterval );
119120
120121 if (snapshotAutoUpdateInterval != null )
121- properties .setSnapshotAutoLoad ( true );
122+ properties .setValue ( ContextKey . SNAPSHOT_AUTO_LOAD , true );
122123
123124 return this ;
124125 }
@@ -130,7 +131,7 @@ public ContextBuilder snapshotAutoUpdateInterval(String snapshotAutoUpdateInterv
130131 * @return ContextBuilder
131132 */
132133 public ContextBuilder regexTimeout (String regexTimeout ) {
133- properties .setRegexTimeout ( regexTimeout );
134+ properties .setValue ( ContextKey . REGEX_TIMEOUT , properties . getRegexTimeoutOrDefault ( regexTimeout ) );
134135 return this ;
135136 }
136137
@@ -139,7 +140,7 @@ public ContextBuilder regexTimeout(String regexTimeout) {
139140 * @return ContextBuilder
140141 */
141142 public ContextBuilder snapshotAutoLoad (boolean snapshotAutoLoad ) {
142- properties .setSnapshotAutoLoad ( snapshotAutoLoad );
143+ properties .setValue ( ContextKey . SNAPSHOT_AUTO_LOAD , snapshotAutoLoad );
143144 return this ;
144145 }
145146
@@ -148,7 +149,7 @@ public ContextBuilder snapshotAutoLoad(boolean snapshotAutoLoad) {
148149 * @return ContextBuilder
149150 */
150151 public ContextBuilder snapshotSkipValidation (boolean snapshotSkipValidation ) {
151- properties .setSnapshotSkipValidation ( snapshotSkipValidation );
152+ properties .setValue ( ContextKey . SNAPSHOT_SKIP_VALIDATION , snapshotSkipValidation );
152153 return this ;
153154 }
154155
@@ -157,10 +158,10 @@ public ContextBuilder snapshotSkipValidation(boolean snapshotSkipValidation) {
157158 * @return ContextBuilder
158159 */
159160 public ContextBuilder silentMode (String retryAfter ) {
160- properties .setSilentMode ( retryAfter );
161+ properties .setValue ( ContextKey . SILENT_MODE , retryAfter );
161162
162163 if (StringUtils .isNotBlank (retryAfter )) {
163- properties .setSnapshotAutoLoad ( true );
164+ properties .setValue ( ContextKey . SNAPSHOT_AUTO_LOAD , true );
164165 }
165166
166167 return this ;
@@ -171,7 +172,7 @@ public ContextBuilder silentMode(String retryAfter) {
171172 * @return ContextBuilder
172173 */
173174 public ContextBuilder local (boolean local ) {
174- properties .setLocal ( local );
175+ properties .setValue ( ContextKey . LOCAL_MODE , local );
175176 return this ;
176177 }
177178
@@ -180,7 +181,7 @@ public ContextBuilder local(boolean local) {
180181 * @return ContextBuilder
181182 */
182183 public ContextBuilder truststorePath (String truststorePath ) {
183- properties .setTruststorePath ( truststorePath );
184+ properties .setValue ( ContextKey . TRUSTSTORE_PATH , truststorePath );
184185 return this ;
185186 }
186187
@@ -189,7 +190,7 @@ public ContextBuilder truststorePath(String truststorePath) {
189190 * @return ContextBuilder
190191 */
191192 public ContextBuilder truststorePassword (String truststorePassword ) {
192- properties .setTruststorePassword ( truststorePassword );
193+ properties .setValue ( ContextKey . TRUSTSTORE_PASSWORD , truststorePassword );
193194 return this ;
194195 }
195196
@@ -198,7 +199,7 @@ public ContextBuilder truststorePassword(String truststorePassword) {
198199 * @return ContextBuilder
199200 */
200201 public ContextBuilder timeoutMs (String timeoutMs ) {
201- properties .setTimeoutMs ( timeoutMs );
202+ properties .setValue ( ContextKey . TIMEOUT_MS , properties . getTimeoutMsOrDefault ( timeoutMs ) );
202203 return this ;
203204 }
204205}
0 commit comments