All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.thunderz99.cosmos.condition.Aggregate Maven / Gradle / Ivy

There is a newer version: 0.7.11
Show newest version
package io.github.thunderz99.cosmos.condition;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

/**
 * Simple data class for aggregate. (e.g. query function, group by)
 */
public class Aggregate {

    /**
     * Default constructor
     */
    public Aggregate() {
    }

    public String function = "";

    public Set groupBy = new LinkedHashSet<>();


    /**
     * condition for the result of aggregation
     */
    public Condition condAfterAggregate = null;

    /**
     * set function
     *
     * 

* aggregate functions like: COUNT, AVG, SUM, MAX, MIN
* see cosmosdb aggregate functions *

* * @param function aggregate functions like: * @return Aggregate */ public static Aggregate function(String function) { Aggregate ret = new Aggregate(); ret.function = function; return ret; } public Aggregate groupBy(String... fields) { if (fields == null || fields.length == 0) { return this; } this.groupBy = new LinkedHashSet<>(List.of(fields)); return this; } /** * Add filter / sort / limit that applies to the result of aggregation * * @param condAfterAggregate * @return aggregate obj self */ public Aggregate conditionAfterAggregate(Condition condAfterAggregate) { this.condAfterAggregate = condAfterAggregate; return this; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy