/** * Adds p into this array projection */ private void addToArray(JsonNode j) { if (j instanceof ArrayNode) { for (Iterator<JsonNode> itr = ((ArrayNode) j).elements(); itr.hasNext();) { addToArray(itr.next()); } } else { ((ArrayNode) node).add(j); } }
public static Projection project(List<? extends Projection> projection) { if (projection.size() == 1) { return projection.get(0); } else { Projection x = new Projection(true); for (Projection p : projection) { x.addToArray(p.toJson()); } return x; } }
/** * <pre> * [ projection ... ] * </pre> */ public static Projection project(Projection... projection) { if (projection.length == 1) { return projection[0]; } else { Projection x = new Projection(true); for (Projection p : projection) { x.addToArray(p.toJson()); } return x; } }