This repository was archived by the owner on May 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
src/main/java/com/launchdarkly/client Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,16 @@ public TargetRule() {
133133 this (attribute , "in" , values );
134134 }
135135
136+ private boolean matchCustom (JsonPrimitive prim , List <Object > values ) {
137+ if (prim .isNumber ()) {
138+ return values .contains (prim .getAsDouble ());
139+ } else if (prim .isBoolean ()) {
140+ return values .contains (prim .getAsBoolean ());
141+ } else {
142+ return values .contains (prim .getAsString ());
143+ }
144+ }
145+
136146 public boolean matchTarget (LDUser user ) {
137147 Object uValue = null ;
138148 if (attribute .equals ("key" )) {
@@ -191,21 +201,14 @@ else if (attribute.equals("anonymous")) {
191201 logger .error ("Invalid custom attribute value in user object: " + elt );
192202 return false ;
193203 }
194- else if (values . contains (elt .getAsString () )) {
204+ else if (matchCustom (elt .getAsJsonPrimitive (), values )) {
195205 return true ;
196206 }
197207 }
198208 return false ;
199209 }
200210 else if (custom .isJsonPrimitive ()) {
201- JsonPrimitive prim = custom .getAsJsonPrimitive ();
202- if (prim .isNumber ()) {
203- return values .contains (custom .getAsDouble ());
204- } else if (prim .isBoolean ()) {
205- return values .contains (custom .getAsBoolean ());
206- } else {
207- return values .contains (custom .getAsString ());
208- }
211+ return matchCustom (custom .getAsJsonPrimitive (), values );
209212 }
210213 }
211214 return false ;
You can’t perform that action at this time.
0 commit comments