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

db.sql.api.impl.cmd.struct.query.GroupBy Maven / Gradle / Ivy

There is a newer version: 1.7.6-RC2
Show newest version
package db.sql.api.impl.cmd.struct.query;

import db.sql.api.Cmd;
import db.sql.api.SqlBuilderContext;
import db.sql.api.cmd.struct.query.IGroupBy;
import db.sql.api.impl.tookit.SqlConst;
import db.sql.api.tookit.CmdUtils;

import java.util.ArrayList;
import java.util.List;

public class GroupBy implements IGroupBy {

    private final List groupByFields = new ArrayList<>();

    @Override
    public GroupBy groupBy(Cmd field) {
        groupByFields.add(field);
        return this;
    }

    @Override
    public List getGroupByFields() {
        return groupByFields;
    }

    @Override
    public StringBuilder sql(Cmd module, Cmd parent, SqlBuilderContext context, StringBuilder sqlBuilder) {
        sqlBuilder.append(SqlConst.GROUP_BY);
        CmdUtils.join(module, this, context, sqlBuilder, this.groupByFields, SqlConst.DELIMITER);
        return sqlBuilder;
    }

    @Override
    public boolean contain(Cmd cmd) {
        return CmdUtils.contain(cmd, this.groupByFields);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy