|
9 | 9 | */ |
10 | 10 | public class Aggregate { |
11 | 11 |
|
12 | | - /** |
13 | | - * Default constructor |
14 | | - */ |
15 | | - public Aggregate() { |
16 | | - } |
17 | | - |
18 | | - public String function = ""; |
19 | | - |
20 | | - public Set<String> groupBy = new LinkedHashSet<>(); |
21 | | - |
22 | | - /** |
23 | | - * set function |
24 | | - * |
25 | | - * <p> |
26 | | - * aggregate functions like: COUNT, AVG, SUM, MAX, MIN <br> |
27 | | - * see <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/sql-query-aggregate-functions">cosmosdb aggregate functions</a> |
28 | | - * </p> |
29 | | - * |
30 | | - * |
31 | | - * @param function aggregate functions like: |
32 | | - * @return Aggregate |
33 | | - */ |
34 | | - public static Aggregate function(String function) { |
35 | | - |
36 | | - Aggregate ret = new Aggregate(); |
37 | | - ret.function = function; |
38 | | - |
39 | | - return ret; |
40 | | - } |
41 | | - |
42 | | - |
43 | | - public Aggregate groupBy(String... fields) { |
44 | | - |
45 | | - if (fields == null || fields.length == 0) { |
46 | | - return this; |
47 | | - } |
48 | | - |
49 | | - this.groupBy = new LinkedHashSet<>(List.of(fields)); |
50 | | - return this; |
51 | | - } |
| 12 | + /** |
| 13 | + * Default constructor |
| 14 | + */ |
| 15 | + public Aggregate() { |
| 16 | + } |
| 17 | + |
| 18 | + public String function = ""; |
| 19 | + |
| 20 | + public Set<String> groupBy = new LinkedHashSet<>(); |
| 21 | + |
| 22 | + |
| 23 | + /** |
| 24 | + * condition for the result of aggregation |
| 25 | + */ |
| 26 | + public Condition condAfterAggregate = null; |
| 27 | + |
| 28 | + /** |
| 29 | + * set function |
| 30 | + * |
| 31 | + * <p> |
| 32 | + * aggregate functions like: COUNT, AVG, SUM, MAX, MIN <br> |
| 33 | + * see <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/sql-query-aggregate-functions">cosmosdb aggregate functions</a> |
| 34 | + * </p> |
| 35 | + * |
| 36 | + * @param function aggregate functions like: |
| 37 | + * @return Aggregate |
| 38 | + */ |
| 39 | + public static Aggregate function(String function) { |
| 40 | + |
| 41 | + Aggregate ret = new Aggregate(); |
| 42 | + ret.function = function; |
| 43 | + |
| 44 | + return ret; |
| 45 | + } |
| 46 | + |
| 47 | + |
| 48 | + public Aggregate groupBy(String... fields) { |
| 49 | + |
| 50 | + if (fields == null || fields.length == 0) { |
| 51 | + return this; |
| 52 | + } |
| 53 | + |
| 54 | + this.groupBy = new LinkedHashSet<>(List.of(fields)); |
| 55 | + return this; |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Add filter / sort / limit that applies to the result of aggregation |
| 60 | + * |
| 61 | + * @param condAfterAggregate |
| 62 | + * @return aggregate obj self |
| 63 | + */ |
| 64 | + public Aggregate conditionAfterAggregate(Condition condAfterAggregate) { |
| 65 | + this.condAfterAggregate = condAfterAggregate; |
| 66 | + return this; |
| 67 | + } |
| 68 | + |
52 | 69 |
|
53 | 70 | } |
0 commit comments