@Test @Ignore public void testFromJson() { ObjectNode node = null; ForEachExpression expResult = null; ForEachExpression result = ForEachExpression.fromJson(node); assertEquals(expResult, result); }
public static ForEachExpression fromJson(ObjectNode node) { if (node.size() == 1) { JsonNode argNode = node.get("$foreach"); if (argNode instanceof ObjectNode) { ObjectNode objArg = (ObjectNode) argNode; if (objArg.size() == 2) { JsonNode updateNode = null; JsonNode queryNode = null; Path field = null; for (Iterator<Map.Entry<String, JsonNode>> itr = objArg.fields(); itr.hasNext();) { Map.Entry<String, JsonNode> entry = itr.next(); if ("$update".equals(entry.getKey())) { updateNode = entry.getValue(); } else { field = new Path(entry.getKey()); queryNode = entry.getValue(); } } if (queryNode != null && updateNode != null && field != null) { return new ForEachExpression(field, UpdateQueryExpression.fromJson(queryNode), ForEachUpdateExpression.fromJson(updateNode)); } } } } throw Error.get(QueryConstants.ERR_INVALID_ARRAY_UPDATE_EXPRESSION, node.toString()); }
ForEachExpression extends ArrayUpdateExpression { public static ForEachExpression fromJson(ObjectNode node) { if (node.size() == 1) { JsonNode argNode = node.get("$foreach"); if (argNode instanceof ObjectNode) { ObjectNode objArg = (ObjectNode) argNode; if (objArg.size() == 2) { JsonNode updateNode = null; JsonNode queryNode = null; Path field = null; for (Iterator<Map.Entry<String, JsonNode>> itr = objArg.fields(); itr.hasNext();) { Map.Entry<String, JsonNode> entry = itr.next(); if ("$update".equals(entry.getKey())) { updateNode = entry.getValue(); } else { field = new Path(entry.getKey()); queryNode = entry.getValue(); } } if (queryNode != null && updateNode != null && field != null) { return new ForEachExpression(field, UpdateQueryExpression.fromJson(queryNode), ForEachUpdateExpression.fromJson(updateNode)); } } } } throw Error.get(QueryConstants.ERR_INVALID_ARRAY_UPDATE_EXPRESSION, node.toString()); } }
ForEachExpression extends ArrayUpdateExpression { public static ForEachExpression fromJson(ObjectNode node) { if (node.size() == 1) { JsonNode argNode = node.get("$foreach"); if (argNode instanceof ObjectNode) { ObjectNode objArg = (ObjectNode) argNode; if (objArg.size() == 2) { JsonNode updateNode = null; JsonNode queryNode = null; Path field = null; for (Iterator<Map.Entry<String, JsonNode>> itr = objArg.fields(); itr.hasNext();) { Map.Entry<String, JsonNode> entry = itr.next(); if ("$update".equals(entry.getKey())) { updateNode = entry.getValue(); } else { field = new Path(entry.getKey()); queryNode = entry.getValue(); } } if (queryNode != null && updateNode != null && field != null) { return new ForEachExpression(field, UpdateQueryExpression.fromJson(queryNode), ForEachUpdateExpression.fromJson(updateNode)); } } } } throw Error.get(QueryConstants.ERR_INVALID_ARRAY_UPDATE_EXPRESSION, node.toString()); } ForEachExpression(Path field, QueryExpression query, UpdateExpression update); }
ForEachExpression extends ArrayUpdateExpression { public static ForEachExpression fromJson(ObjectNode node) { if (node.size() == 1) { JsonNode argNode = node.get("$foreach"); if (argNode instanceof ObjectNode) { ObjectNode objArg = (ObjectNode) argNode; if (objArg.size() == 2) { JsonNode updateNode = null; JsonNode queryNode = null; Path field = null; for (Iterator<Map.Entry<String, JsonNode>> itr = objArg.fields(); itr.hasNext();) { Map.Entry<String, JsonNode> entry = itr.next(); if ("$update".equals(entry.getKey())) { updateNode = entry.getValue(); } else { field = new Path(entry.getKey()); queryNode = entry.getValue(); } } if (queryNode != null && updateNode != null && field != null) { return new ForEachExpression(field, UpdateQueryExpression.fromJson(queryNode), ForEachUpdateExpression.fromJson(updateNode)); } } } } throw Error.get(QueryConstants.ERR_INVALID_ARRAY_UPDATE_EXPRESSION, node.toString()); } ForEachExpression(Path field, QueryExpression query, UpdateExpression update); Path getField(); QueryExpression getQuery(); UpdateExpression getUpdate(); @Override JsonNode toJson(); static ForEachExpression fromJson(ObjectNode node); @Override int hashCode(); @Override boolean equals(Object obj); }
ForEachExpression extends ArrayUpdateExpression { public static ForEachExpression fromJson(ObjectNode node) { if (node.size() == 1) { JsonNode argNode = node.get("$foreach"); if (argNode instanceof ObjectNode) { ObjectNode objArg = (ObjectNode) argNode; if (objArg.size() == 2) { JsonNode updateNode = null; JsonNode queryNode = null; Path field = null; for (Iterator<Map.Entry<String, JsonNode>> itr = objArg.fields(); itr.hasNext();) { Map.Entry<String, JsonNode> entry = itr.next(); if ("$update".equals(entry.getKey())) { updateNode = entry.getValue(); } else { field = new Path(entry.getKey()); queryNode = entry.getValue(); } } if (queryNode != null && updateNode != null && field != null) { return new ForEachExpression(field, UpdateQueryExpression.fromJson(queryNode), ForEachUpdateExpression.fromJson(updateNode)); } } } } throw Error.get(QueryConstants.ERR_INVALID_ARRAY_UPDATE_EXPRESSION, node.toString()); } ForEachExpression(Path field, QueryExpression query, UpdateExpression update); Path getField(); QueryExpression getQuery(); UpdateExpression getUpdate(); @Override JsonNode toJson(); static ForEachExpression fromJson(ObjectNode node); @Override int hashCode(); @Override boolean equals(Object obj);  }