/** * Generates the code for a new JmesPathValueProjection. * * @param valueProjection JmesPath value projection type * @param aVoid void * @return String that represents a call to * the new value projection * @throws InvalidTypeException */ @Override public String visit(final JmesPathValueProjection valueProjection, final Void aVoid) throws InvalidTypeException { return "new JmesPathValueProjection( " + valueProjection.getLhsExpr() .accept(this, aVoid) + ", " + valueProjection.getRhsExpr() .accept(this, aVoid) + ")"; }
private static JmesPathExpression jsonToValueProjection(JsonNode jsonNode) { List<JmesPathExpression> args = getChildren(jsonNode); return new JmesPathValueProjection(args.get(0), args.get(1)); }
/** * Evaluates the object projection expression. * This will create a list of the values of the JSON * object(lhs), and project the right hand side of the * projection onto the list of values. * * @param valueProjection JmesPath value projection type * @param input Input json node against which evaluation is done * @return Result of the value projection evaluation * @throws InvalidTypeException */ @Override public JsonNode visit(JmesPathValueProjection valueProjection, JsonNode input) throws InvalidTypeException { JsonNode projectedResult = valueProjection.getLhsExpr().accept(this, input); if (projectedResult.isObject()) { ArrayNode projectedArrayNode = ObjectMapperSingleton.getObjectMapper().createArrayNode(); Iterator<JsonNode> elements = projectedResult.elements(); while (elements.hasNext()) { JsonNode projectedElement = valueProjection.getRhsExpr().accept(this, elements.next()); if (projectedElement != null) { projectedArrayNode.add(projectedElement); } } return projectedArrayNode; } return NullNode.getInstance(); }
private static JmesPathExpression jsonToValueProjection(JsonNode jsonNode) { List<JmesPathExpression> args = getChildren(jsonNode); return new JmesPathValueProjection(args.get(0), args.get(1)); }
/** * Generates the code for a new JmesPathValueProjection. * * @param valueProjection JmesPath value projection type * @param aVoid void * @return String that represents a call to * the new value projection * @throws InvalidTypeException */ @Override public String visit(final JmesPathValueProjection valueProjection, final Void aVoid) throws InvalidTypeException { return "new JmesPathValueProjection( " + valueProjection.getLhsExpr() .accept(this, aVoid) + ", " + valueProjection.getRhsExpr() .accept(this, aVoid) + ")"; }
/** * Evaluates the object projection expression. * This will create a list of the values of the JSON * object(lhs), and project the right hand side of the * projection onto the list of values. * * @param valueProjection JmesPath value projection type * @param input Input json node against which evaluation is done * @return Result of the value projection evaluation * @throws InvalidTypeException */ @Override public JsonNode visit(JmesPathValueProjection valueProjection, JsonNode input) throws InvalidTypeException { JsonNode projectedResult = valueProjection.getLhsExpr().accept(this, input); if (projectedResult.isObject()) { ArrayNode projectedArrayNode = ObjectMapperSingleton.getObjectMapper().createArrayNode(); Iterator<JsonNode> elements = projectedResult.elements(); while (elements.hasNext()) { JsonNode projectedElement = valueProjection.getRhsExpr().accept(this, elements.next()); if (projectedElement != null) { projectedArrayNode.add(projectedElement); } } return projectedArrayNode; } return NullNode.getInstance(); }
/** * Evaluates the object projection expression. * This will create a list of the values of the JSON * object(lhs), and project the right hand side of the * projection onto the list of values. * * @param valueProjection JmesPath value projection type * @param input Input json node against which evaluation is done * @return Result of the value projection evaluation * @throws InvalidTypeException */ @Override public JsonNode visit(JmesPathValueProjection valueProjection, JsonNode input) throws InvalidTypeException { JsonNode projectedResult = valueProjection.getLhsExpr().accept(this, input); if (projectedResult.isObject()) { ArrayNode projectedArrayNode = ObjectMapperSingleton.getObjectMapper().createArrayNode(); Iterator<JsonNode> elements = projectedResult.elements(); while (elements.hasNext()) { JsonNode projectedElement = valueProjection.getRhsExpr().accept(this, elements.next()); if (projectedElement != null) { projectedArrayNode.add(projectedElement); } } return projectedArrayNode; } return NullNode.getInstance(); }