3939
4040import org .slf4j .Logger ;
4141import org .slf4j .LoggerFactory ;
42-
42+
4343final class ConditionEvaluator {
4444 private static final int MAX_CONDITION_RECURSION_DEPTH = 10 ;
4545 private static final Logger logger = LoggerFactory .getLogger (ConditionEvaluator .class );
@@ -49,7 +49,7 @@ final class ConditionEvaluator {
4949 * Evaluates server conditions and assigns a boolean value to each condition.
5050 *
5151 * @param conditions List of conditions which are to be evaluated.
52- * @param context A map with additional metadata used during evaluation.
52+ * @param context A map with additional metadata used during evaluation.
5353 * @return A map of condition to evaluated value.
5454 */
5555 @ NonNull
@@ -58,19 +58,17 @@ Map<String, Boolean> evaluateConditions(
5858 @ Nullable KeysAndValues context ) {
5959 checkNotNull (conditions , "List of conditions must not be null." );
6060 checkArgument (!conditions .isEmpty (), "List of conditions must not be empty." );
61- if (context == null || conditions .isEmpty ()){
61+ if (context == null || conditions .isEmpty ()) {
6262 return ImmutableMap .of ();
6363 }
64- KeysAndValues evaluationContext = context != null
65- ? context
64+ KeysAndValues evaluationContext = context != null
65+ ? context
6666 : new KeysAndValues .Builder ().build ();
6767
6868 Map <String , Boolean > evaluatedConditions = conditions .stream ()
6969 .collect (ImmutableMap .toImmutableMap (
7070 ServerCondition ::getName ,
71- condition ->
72- evaluateCondition (condition .getCondition (), evaluationContext , /* nestingLevel= */ 0 )
73- ));
71+ condition -> evaluateCondition (condition .getCondition (), evaluationContext , /* nestingLevel= */ 0 )));
7472
7573 return evaluatedConditions ;
7674 }
@@ -99,7 +97,6 @@ private boolean evaluateCondition(OneOfCondition condition, KeysAndValues contex
9997 return false ;
10098 }
10199
102-
103100 private boolean evaluateOrCondition (OrCondition condition , KeysAndValues context ,
104101 int nestingLevel ) {
105102 return condition .getConditions ().stream ()
@@ -251,9 +248,8 @@ private BigInteger hashSeededRandomizationId(String seededRandomizationId) {
251248 }
252249
253250 private boolean compareStrings (ImmutableList <String > targetValues , String customSignal ,
254- BiPredicate <String , String > compareFunction ) {
255- return targetValues .stream ().anyMatch (targetValue ->
256- compareFunction .test (customSignal , targetValue ));
251+ BiPredicate <String , String > compareFunction ) {
252+ return targetValues .stream ().anyMatch (targetValue -> compareFunction .test (customSignal , targetValue ));
257253 }
258254
259255 private boolean compareStringRegex (String customSignal , String targetSignal ) {
@@ -265,7 +261,7 @@ private boolean compareStringRegex(String customSignal, String targetSignal) {
265261 }
266262
267263 private boolean compareNumbers (ImmutableList <String > targetValues , String customSignal ,
268- IntPredicate compareFunction ) {
264+ IntPredicate compareFunction ) {
269265 if (targetValues .size () != 1 ) {
270266 logger .warn (String .format (
271267 "Target values must contain 1 element for numeric operations. Target Value: %s" ,
@@ -286,8 +282,8 @@ private boolean compareNumbers(ImmutableList<String> targetValues, String custom
286282 }
287283
288284 private boolean compareSemanticVersions (ImmutableList <String > targetValues ,
289- String customSignal ,
290- IntPredicate compareFunction ) {
285+ String customSignal ,
286+ IntPredicate compareFunction ) {
291287 if (targetValues .size () != 1 ) {
292288 logger .warn (String .format ("Target values must contain 1 element for semantic operation." ));
293289 return false ;
@@ -320,8 +316,8 @@ private int compareSemanticVersions(List<Integer> version1, List<Integer> versio
320316
321317 for (int i = 0 ; i < maxLength ; i ++) {
322318 // Default to 0 if segment is missing
323- int v1 = i < version1Size ? version1 .get (i ) : 0 ;
324- int v2 = i < version2Size ? version2 .get (i ) : 0 ;
319+ int v1 = i < version1Size ? version1 .get (i ) : 0 ;
320+ int v2 = i < version2Size ? version2 .get (i ) : 0 ;
325321
326322 int comparison = Integer .compare (v1 , v2 );
327323 if (comparison != 0 ) {
@@ -334,8 +330,8 @@ private int compareSemanticVersions(List<Integer> version1, List<Integer> versio
334330
335331 private List <Integer > parseSemanticVersion (String versionString ) {
336332 return Arrays .stream (versionString .split ("\\ ." ))
337- .map (Integer ::parseInt )
338- .collect (Collectors .toList ());
333+ .map (Integer ::parseInt )
334+ .collect (Collectors .toList ());
339335 }
340336
341337 private boolean validateSemanticVersion (String version ) {
0 commit comments