/** * <pre> * { field: <pattern>, include: <include>, match: <query>, projection: <projection>, sort: <sort> } * </pre> */ public static Projection array(String pattern, Query match, boolean include, Projection projection, Sort sort) { Projection p = new Projection(false); p.add("field", pattern).add("include", include).add("match", match.toJson()); if (projection != null) { p.add("projection", projection.toJson()); } if (sort != null) { p.add("sort", sort.toJson()); } return p; }
/** * <pre> * { field: <pattern>, include: <include>, recursive: <recursive> } * </pre> */ public static Projection field(String pattern, boolean include, boolean recursive) { Projection p = new Projection(false); p.add("field", pattern).add("include", include).add("recursive", recursive); return p; }
/** * <pre> * { field: <pattern>, include: <include>, range: [from,to], projection: <projection>, sort: <sort> } * </pre> */ public static Projection array(String pattern, Integer from, Integer to, boolean include, Projection projection, Sort sort) { Projection p = new Projection(false); ArrayNode a = JsonNodeFactory.instance.arrayNode(); a.add(JsonNodeFactory.instance.numberNode(from)); if (to != null) { a.add(JsonNodeFactory.instance.numberNode(to)); } else { a.add(JsonNodeFactory.instance.nullNode()); } p.add("field", pattern).add("include", include).add("range", a); if (projection != null) { p.add("projection", projection.toJson()); } if (sort != null) { p.add("sort", sort.toJson()); } return p; }