class MultiLevelQueryBuilder extends ClientQueryBuilder {

    @Override
    public ClientMultiLevelQuery build() {
        ClientMultiLevelQuery query = new ClientMultiLevelQuery();
        buildCommon(query);

        if (getAggregates() != null) {
            query.getSelect().setAggregations(getAggregates());
        }
        if (getGroups() != null) {
            query.setGroupBy(new ClientQueryGroupBy().setGroups(getGroups()));
        }
        if (getOrder() != null) {
            query.setOrderBy((List<ClientGenericOrder>) getOrder());
        }

        return query;
    }

}