Source:
private boolean executeSelectorTree(QueryNode node, DocumentRevision rev) { if (node instanceof AndQueryNode) { boolean passed = true; AndQueryNode andNode = (AndQueryNode) node; for (QueryNode child: andNode.children) { passed = passed && executeSelectorTree(child, rev); } return passed; } if (node instanceof OrQueryNode) { boolean passed = false; OrQueryNode orNode = (OrQueryNode) node; for (QueryNode child: orNode.children) { passed = passed || executeSelectorTree(child, rev); } return passed; } else if (node instanceof OperatorExpressionNode) { Map<String, Object> expression = ((OperatorExpressionNode) node).expression; String fieldName = (String) expression.keySet().toArray()[0]; Map<String, Object> operatorExpression; operatorExpression = (Map<String, Object>) expression.get(fieldName); String operator = (String) operatorExpression.keySet().toArray()[0]; boolean invertResult = operator.equals(NOT); if (invertResult) { operatorExpression = (Map<String, Object>) operatorExpression.get(NOT); operator = (String) operatorExpression.keySet().toArray()[0]; } Object expectedValues = operatorExpression.get(operator); if (!(expectedValues instanceof List)) { expectedValues = Arrays.asList(expectedValues); } Object actual = ValueExtractor.extractValueForFieldName(fieldName, rev); boolean passed = false; for (Object expected : (List<Object>) expectedValues) { if (actual instanceof List) { for (Object actualItem: (List<Object>) actual) { passed = passed || valueCompare(actualItem, operator, expected); } } else { passed = passed || valueCompare(actual, operator, expected); } } return invertResult ? !passed : passed; } else { String msg = String.format("Found unexpected selector execution tree: %s", node); logger.log(Level.SEVERE, msg); return false; } }

Target:
private boolean executeSelectorTree(QueryNode node, DocumentRevision rev) { if (node instanceof AndQueryNode) { boolean passed = true; AndQueryNode andNode = (AndQueryNode) node; for (QueryNode child: andNode.children) { passed = passed && executeSelectorTree(child, rev); } return passed; } if (node instanceof OrQueryNode) { boolean passed = false; OrQueryNode orNode = (OrQueryNode) node; for (QueryNode child: orNode.children) { passed = passed || executeSelectorTree(child, rev); } return passed; } else if (node instanceof OperatorExpressionNode) { Map<String, Object> expression = ((OperatorExpressionNode) node).expression; String fieldName = (String) expression.keySet().toArray()[0]; Map<String, Object> operatorExpression; operatorExpression = (Map<String, Object>) expression.get(fieldName); String operator = (String) operatorExpression.keySet().toArray()[0]; boolean invertResult = operator.equals(NOT); if (invertResult) { operatorExpression = (Map<String, Object>) operatorExpression.get(NOT); operator = (String) operatorExpression.keySet().toArray()[0]; } Object expected = operatorExpression.get(operator); Object actual = ValueExtractor.extractValueForFieldName(fieldName, rev); if (!(expected instanceof List)) { expected = Arrays.asList(expected); } if (!(actual instanceof List)) { actual = Arrays.asList(actual); } if (operator.equals(IN)) { operator = EQ; } boolean passed = false; for (Object expectedItem : (List<Object>) expected) { for (Object actualItem: (List<Object>) actual) { passed = passed || valueCompare(actualItem, operator, expectedItem); } } return invertResult ? !passed : passed; } else { String msg = String.format("Found unexpected selector execution tree: %s", node); logger.log(Level.SEVERE, msg); return false; } }