/** * Compare a value to a list. Returns: * <ul> * <li>_eq: if all values in list are equal to value</li> * <li>_lt: if value is less than all values in the list</li> * <li>_lte: if value is less than or equal to all the values in the * list</li> * <li>_gt: if value is greater than all values in the list</li> * <li>_gte: if value is greater or equal to all the values in the list</li> * <li>_neq: otherwise</li> * <ul> */ private static BinaryComparisonOperator lvCompare(Object value, List<Object> list, Type t) { int cmp = 0; if (value != null) { if (list != null && !list.isEmpty()) { for (Object x : list) { cmp = apply(cmp, t.compare(value, x)); } } } return CMP_LOOKUP[cmp]; }
if (lvalueNode != null) { if (fieldMd.getType() instanceof ArrayType) { ldocList = makeList(((ArrayField) fieldMd).getElement().getType(), lvalueNode); } else { ldocValue = fieldMd.getType().fromJson(lvalueNode); if (rvalueNode != null) { if (rfieldMd.getType() instanceof ArrayType) { rdocList = makeList(((ArrayField) rfieldMd).getElement().getType(), rvalueNode); } else { rdocValue = rfieldMd.getType().fromJson(rvalueNode); if (ln == rn) { for (int i = 0; i < ln; i++) { cmp = apply(cmp, type.compare(ldocList.get(i), rdocList.get(i))); if (cmpOp(CMP_LOOKUP[cmp], operator)) { ctx.setResult(true); BinaryComparisonOperator resultOp = lvCompare(rdocValue, ldocList, ((ArrayField) fieldMd).getElement().getType()).invert(); LOGGER.debug("Comparing array with field {} {} {}={}", ldocList, operator, rdocValue, resultOp); if (cmpOp(resultOp, operator)) { ctx.setResult(true); BinaryComparisonOperator resultOp = lvCompare(ldocValue, rdocList, fieldMd.getType()); LOGGER.debug("Comparing field with array {} {} {}={}", ldocValue, operator, rdocList, resultOp); if (cmpOp(resultOp, operator)) { ctx.setResult(true);
public static QueryEvaluator getInstance(QueryExpression expr, FieldTreeNode context) { QueryEvaluator ret = null; if (expr instanceof ValueComparisonExpression) { return new ValueComparisonEvaluator((ValueComparisonExpression) expr, context); } else if (expr instanceof FieldComparisonExpression) { return new FieldComparisonEvaluator((FieldComparisonExpression) expr, context); } else if (expr instanceof RegexMatchExpression) { return new RegexEvaluator((RegexMatchExpression) expr, context); } else if (expr instanceof NaryRelationalExpression) { return new NaryRelationalExpressionEvaluator((NaryRelationalExpression) expr, context); } else if (expr instanceof UnaryLogicalExpression) { return new UnaryLogicalExpressionEvaluator((UnaryLogicalExpression) expr, context); } else if (expr instanceof NaryLogicalExpression) { return new NaryLogicalExpressionEvaluator((NaryLogicalExpression) expr, context); } else if (expr instanceof ArrayContainsExpression) { return new ArrayContainsEvaluator((ArrayContainsExpression) expr, context); } else if (expr instanceof ArrayMatchExpression) { return new ArrayMatchEvaluator((ArrayMatchExpression) expr, context); } return ret; } }
if (lvalueNode != null) { if (fieldMd.getType() instanceof ArrayType) { ldocList = makeList(((ArrayField) fieldMd).getElement().getType(), lvalueNode); } else { ldocValue = fieldMd.getType().fromJson(lvalueNode); if (rvalueNode != null) { if (rfieldMd.getType() instanceof ArrayType) { rdocList = makeList(((ArrayField) rfieldMd).getElement().getType(), rvalueNode); } else { rdocValue = rfieldMd.getType().fromJson(rvalueNode); if (ln == rn) { for (int i = 0; i < ln; i++) { cmp = apply(cmp, type.compare(ldocList.get(i), rdocList.get(i))); if (cmpOp(CMP_LOOKUP[cmp], operator)) { ctx.setResult(true); BinaryComparisonOperator resultOp = lvCompare(rdocValue, ldocList, ((ArrayField) fieldMd).getElement().getType()).invert(); LOGGER.debug("Comparing array with field {} {} {}={}", ldocList, operator, rdocValue, resultOp); if (cmpOp(resultOp, operator)) { ctx.setResult(true); BinaryComparisonOperator resultOp = lvCompare(ldocValue, rdocList, fieldMd.getType()); LOGGER.debug("Comparing field with array {} {} {}={}", ldocValue, operator, rdocList, resultOp); if (cmpOp(resultOp, operator)) { ctx.setResult(true);
public static QueryEvaluator getInstance(QueryExpression expr, FieldTreeNode context) { QueryEvaluator ret = null; if (expr instanceof ValueComparisonExpression) { return new ValueComparisonEvaluator((ValueComparisonExpression) expr, context); } else if (expr instanceof FieldComparisonExpression) { return new FieldComparisonEvaluator((FieldComparisonExpression) expr, context); } else if (expr instanceof RegexMatchExpression) { return new RegexEvaluator((RegexMatchExpression) expr, context); } else if (expr instanceof NaryValueRelationalExpression) { return new NaryValueRelationalExpressionEvaluator((NaryValueRelationalExpression) expr, context); } else if (expr instanceof NaryFieldRelationalExpression) { return new NaryFieldRelationalExpressionEvaluator((NaryFieldRelationalExpression) expr, context); } else if (expr instanceof UnaryLogicalExpression) { return new UnaryLogicalExpressionEvaluator((UnaryLogicalExpression) expr, context); } else if (expr instanceof NaryLogicalExpression) { return new NaryLogicalExpressionEvaluator((NaryLogicalExpression) expr, context); } else if (expr instanceof ArrayContainsExpression) { return new ArrayContainsEvaluator((ArrayContainsExpression) expr, context); } else if (expr instanceof ArrayMatchExpression) { return new ArrayMatchEvaluator((ArrayMatchExpression) expr, context); } return ret; } }
public static QueryEvaluator getInstance(QueryExpression expr, FieldTreeNode context) { QueryEvaluator ret = null; if (expr instanceof ValueComparisonExpression) { return new ValueComparisonEvaluator((ValueComparisonExpression) expr, context); } else if (expr instanceof FieldComparisonExpression) { return new FieldComparisonEvaluator((FieldComparisonExpression) expr, context); } else if (expr instanceof RegexMatchExpression) { return new RegexEvaluator((RegexMatchExpression) expr, context); } else if (expr instanceof NaryValueRelationalExpression) { return new NaryValueRelationalExpressionEvaluator((NaryValueRelationalExpression) expr, context); } else if (expr instanceof NaryFieldRelationalExpression) { return new NaryFieldRelationalExpressionEvaluator((NaryFieldRelationalExpression) expr, context); } else if (expr instanceof UnaryLogicalExpression) { return new UnaryLogicalExpressionEvaluator((UnaryLogicalExpression) expr, context); } else if (expr instanceof NaryLogicalExpression) { return new NaryLogicalExpressionEvaluator((NaryLogicalExpression) expr, context); } else if (expr instanceof ArrayContainsExpression) { return new ArrayContainsEvaluator((ArrayContainsExpression) expr, context); } else if (expr instanceof ArrayMatchExpression) { return new ArrayMatchEvaluator((ArrayMatchExpression) expr, context); } return ret; } }
/** * Compare a value to a list. Returns: * <ul> * <li>_eq: if all values in list are equal to value</li> * <li>_lt: if value is less than all values in the list</li> * <li>_lte: if value is less than or equal to all the values in the * list</li> * <li>_gt: if value is greater than all values in the list</li> * <li>_gte: if value is greater or equal to all the values in the list</li> * <li>_neq: otherwise</li> * <ul> */ private static BinaryComparisonOperator lvCompare(Object value, List<Object> list, Type t) { int cmp = 0; if (value != null) { if (list != null && !list.isEmpty()) { for (Object x : list) { cmp = apply(cmp, t.compare(value, x)); } } } return CMP_LOOKUP[cmp]; }