You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @param connectionInformation information about remote Izanami instance
41
+
* @param errorStrategy default error strategy to use in case client fails to fetch remote Izanami. This can be overrided at request level.
42
+
* @param cacheConfiguration cache configuration to use
43
+
* @param httpClient httpClient to use
44
+
* @param callTimeout timeout for remote instance http calls
45
+
* @param idsToPreload flag ids to preload, preloading id prevent from payin the cost of querying remote Izanami first time flags are needed
46
+
* @param castStrategy default strategy to use to cast non-boolean values in boolean when needed. Possible values are STRICT (trying to cast non boolean value to boolean value will fail) and LAX (empty string, numeric 0 and null are false, everything else is true).
* Retrieve boolean value of the flag given request
155
+
* @param request request to match
156
+
* @return a CompletableFuture that will resolve with requested feature value. If feature does not have a boolean value:
157
+
* <ul>
158
+
* <li>if a LAX BooleanCastStrategy was specified, value will be casted to boolean (empty string, numeric 0 and null are false, everything else is true).</li>
159
+
* <li>if STRICT BooleanCastStrategy was specified (or if no strategy was specified) error strategy will be used to determine value to return.</li>
* Indicate when client is loaded. A loaded client has fetch ids to preload (if provided). If no ids were provided, client is ready immediately after its instantiation.
177
+
* @return a CompletableFuture that resolve when client has loaded id to preload (if any).
178
+
*/
135
179
publicCompletableFuture<Void> isLoaded() {
136
180
returnloader;
137
181
}
@@ -211,7 +255,8 @@ public IzanamiClientBuilder withPreloadedFeatures(String... ids) {
211
255
}
212
256
213
257
/**
214
-
* Specify boolean cast strategy to use for this client.
258
+
* Default strategy to use to cast non-boolean values in boolean when needed.
259
+
* Possible values are STRICT (trying to cast non-boolean value to boolean value will fail) and LAX (empty string, numeric 0 and null are false, everything else is true).
215
260
* This strategy can be overridden both at query and query feature levels.
Copy file name to clipboardExpand all lines: src/main/java/fr/maif/features/results/IzanamiResult.java
+23Lines changed: 23 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,9 @@
7
7
importjava.math.BigDecimal;
8
8
importjava.util.Map;
9
9
10
+
/**
11
+
* Represent result of multiple flag evaluation.
12
+
*/
10
13
publicclassIzanamiResult {
11
14
publicfinalMap<String, Result> results;
12
15
privatefinalBooleanCastStrategycastStrategy;
@@ -18,14 +21,34 @@ public IzanamiResult(Map<String, Result> results, BooleanCastStrategy castStrate
18
21
this.defaultStrategy = defaultStrategy;
19
22
}
20
23
24
+
/**
25
+
* Retrieve string value of the flag with the given id
26
+
* @param feature feature id
27
+
* @return string value of given flag. If feature does not have a string value error strategy will be used to determine value to return.
28
+
*/
21
29
publicStringstringValue(Stringfeature) {
22
30
returnresults.getOrDefault(feature, newError(defaultStrategy, newIzanamiError("This feature hasn't been requested"))).stringValue();
23
31
}
24
32
33
+
34
+
/**
35
+
* Retrieve boolean value of the flag with given id
36
+
* @param feature feature id
37
+
* @return boolean value of given flag. If feature does not have a boolean value:
38
+
* <ul>
39
+
* <li>if a LAX BooleanCastStrategy was specified, value will be casted to boolean (empty string, numeric 0 and null are false, everything else is true).</li>
40
+
* <li>if STRICT BooleanCastStrategy was specified (or if no strategy was specified) error strategy will be used to determine value to return.</li>
41
+
* </ul>
42
+
*/
25
43
publicBooleanbooleanValue(Stringfeature) {
26
44
returnresults.getOrDefault(feature, newError(defaultStrategy, newIzanamiError("This feature hasn't been requested"))).booleanValue(castStrategy);
27
45
}
28
46
47
+
/**
48
+
* Retrieve number value of the flag with the given id
49
+
* @param feature feature id
50
+
* @return number value of given flag. If feature does not have a number value error strategy will be used to determine value to return.
51
+
*/
29
52
publicBigDecimalnumberValue(Stringfeature) {
30
53
returnresults.getOrDefault(feature, newError(defaultStrategy, newIzanamiError("This feature hasn't been requested"))).numberValue();
0 commit comments