/** * Parses a relational expression using the given object node */ public static RelationalExpression fromJson(ObjectNode node) { JsonNode x = node.get("regex"); if (x != null) { return RegexMatchExpression.fromJson(node); } else { x = node.get("op"); if (x != null) { String op = x.asText(); if (BinaryComparisonOperator.fromString(op) != null) { return BinaryRelationalExpression.fromJson(node); } else if (NaryRelationalOperator.fromString(op) != null) { return NaryRelationalExpression.fromJson(node); } } } throw Error.get(QueryConstants.ERR_INVALID_COMPARISON_EXPRESSION, node.toString()); } }
/** * Parses a relational expression using the given object node */ public static RelationalExpression fromJson(ObjectNode node) { JsonNode x = node.get("regex"); if (x != null) { return RegexMatchExpression.fromJson(node); } else { x = node.get("op"); if (x != null) { String op = x.asText(); if (BinaryComparisonOperator.fromString(op) != null) { return BinaryRelationalExpression.fromJson(node); } else if (NaryRelationalOperator.fromString(op) != null) { return NaryRelationalExpression.fromJson(node); } } } throw Error.get(QueryConstants.ERR_INVALID_COMPARISON_EXPRESSION, node.toString()); } }
/** * Parses a field comparison or value comparison expression from the given * json object */ public static BinaryRelationalExpression fromJson(ObjectNode node) { if (node.size() == 3) { JsonNode x = node.get("op"); if (x != null) { BinaryComparisonOperator op = BinaryComparisonOperator.fromString(x.asText()); if (op != null) { x = node.get("field"); if (x != null) { Path field = new Path(x.asText()); x = node.get("rfield"); if (x != null) { return new FieldComparisonExpression(field, op, new Path(x.asText())); } else { x = node.get("rvalue"); if (x != null) { return new ValueComparisonExpression(field, op, Value.fromJson(x)); } } } } } } throw Error.get(QueryConstants.ERR_INVALID_COMPARISON_EXPRESSION, node.toString()); } }
/** * Parses a field comparison or value comparison expression from the given * json object */ public static BinaryRelationalExpression fromJson(ObjectNode node) { if (node.size() == 3) { JsonNode x = node.get("op"); if (x != null) { BinaryComparisonOperator op = BinaryComparisonOperator.fromString(x.asText()); if (op != null) { x = node.get("field"); if (x != null) { Path field = new Path(x.asText()); x = node.get("rfield"); if (x != null) { return new FieldComparisonExpression(field, op, new Path(x.asText())); } else { x = node.get("rvalue"); if (x != null) { return new ValueComparisonExpression(field, op, Value.fromJson(x)); } } } } } } throw Error.get(QueryConstants.ERR_INVALID_COMPARISON_EXPRESSION, node.toString()); } }