@Test public void testToJson() throws IOException { List<RValueExpression> l = new ArrayList<>(); ArrayAddExpression instance = new ArrayAddExpression(Path.EMPTY, UpdateOperator._set, l); l.add(new RValueExpression(Path.EMPTY)); JsonNode expResult = JsonUtils.json("{\"$set\":{\"\":{\"$valueof\":\"\"}}}"); JsonNode result = instance.toJson(); assertEquals(expResult, result); }
@Override public JsonNode toJson() { ObjectNode node = getFactory().objectNode(); ObjectNode args = getFactory().objectNode(); if (values.size() == 1) { args.set(field.toString(), values.get(0).toJson()); } else { ArrayNode arr = getFactory().arrayNode(); for (RValueExpression v : values) { arr.add(v.toJson()); } args.set(field.toString(), arr); } node.set(op.toString(), args); return node; }
ArrayAddExpression extends ArrayUpdateExpression { @Override public JsonNode toJson() { ObjectNode node = getFactory().objectNode(); ObjectNode args = getFactory().objectNode(); if (values.size() == 1) { args.set(field.toString(), values.get(0).toJson()); } else { ArrayNode arr = getFactory().arrayNode(); for (RValueExpression v : values) { arr.add(v.toJson()); } args.set(field.toString(), arr); } node.set(op.toString(), args); return node; } }
ArrayAddExpression extends ArrayUpdateExpression { @Override public JsonNode toJson() { ObjectNode node = getFactory().objectNode(); ObjectNode args = getFactory().objectNode(); if (values.size() == 1) { args.set(field.toString(), values.get(0).toJson()); } else { ArrayNode arr = getFactory().arrayNode(); for (RValueExpression v : values) { arr.add(v.toJson()); } args.set(field.toString(), arr); } node.set(op.toString(), args); return node; } ArrayAddExpression(Path field, UpdateOperator op, List<RValueExpression> list); }
ArrayAddExpression extends ArrayUpdateExpression { @Override public JsonNode toJson() { ObjectNode node = getFactory().objectNode(); ObjectNode args = getFactory().objectNode(); if (values.size() == 1) { args.set(field.toString(), values.get(0).toJson()); } else { ArrayNode arr = getFactory().arrayNode(); for (RValueExpression v : values) { arr.add(v.toJson()); } args.set(field.toString(), arr); } node.set(op.toString(), args); return node; } ArrayAddExpression(Path field, UpdateOperator op, List<RValueExpression> list); Path getField(); List<RValueExpression> getValues(); UpdateOperator getOp(); @Override JsonNode toJson(); static ArrayAddExpression fromJson(ObjectNode node); @Override int hashCode(); @Override boolean equals(Object obj); }
ArrayAddExpression extends ArrayUpdateExpression { @Override public JsonNode toJson() { ObjectNode node = getFactory().objectNode(); ObjectNode args = getFactory().objectNode(); if (values.size() == 1) { args.set(field.toString(), values.get(0).toJson()); } else { ArrayNode arr = getFactory().arrayNode(); for (RValueExpression v : values) { arr.add(v.toJson()); } args.set(field.toString(), arr); } node.set(op.toString(), args); return node; } ArrayAddExpression(Path field, UpdateOperator op, List<RValueExpression> list); Path getField(); List<RValueExpression> getValues(); UpdateOperator getOp(); @Override JsonNode toJson(); static ArrayAddExpression fromJson(ObjectNode node); @Override int hashCode(); @Override boolean equals(Object obj);  }