/** * Parses a query expression from the given json node */ public static QueryExpression fromJson(JsonNode node) { if (node instanceof ObjectNode) { ObjectNode onode = (ObjectNode) node; // If there is only one field, then that field must be a // logical operator String firstField = onode.fieldNames().next(); if (UnaryLogicalOperator.fromString(firstField) != null) { return UnaryLogicalExpression.fromJson(onode); } else if (NaryLogicalOperator.fromString(firstField) != null) { return NaryLogicalExpression.fromJson(onode); } else { return ComparisonExpression.fromJson(onode); } } else { throw Error.get(QueryConstants.ERR_INVALID_QUERY, node.toString()); } }
/** * Parses a query expression from the given json node */ public static QueryExpression fromJson(JsonNode node) { if (node instanceof ObjectNode) { ObjectNode onode = (ObjectNode) node; // If there is only one field, then that field must be a // logical operator String firstField = onode.fieldNames().next(); if (UnaryLogicalOperator.fromString(firstField) != null) { return UnaryLogicalExpression.fromJson(onode); } else if (NaryLogicalOperator.fromString(firstField) != null) { return NaryLogicalExpression.fromJson(onode); } else { return ComparisonExpression.fromJson(onode); } } else { throw Error.get(QueryConstants.ERR_INVALID_QUERY, node.toString()); } }