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

org.influxdb.querybuilder.SelectionSubQueryImpl Maven / Gradle / Ivy

The newest version!
package org.influxdb.querybuilder;

import java.util.Arrays;
import org.influxdb.querybuilder.clauses.OperationClause;
import org.influxdb.querybuilder.clauses.SimpleClause;
import org.influxdb.querybuilder.clauses.RawFromClause;
import org.influxdb.querybuilder.clauses.SimpleFromClause;
import org.influxdb.querybuilder.clauses.MultipleFromClause;
import org.influxdb.querybuilder.clauses.FromClause;

public class SelectionSubQueryImpl extends SubQuery
    implements Selection, WithSubquery {

  private final SelectionCoreImpl selectionCore;

  SelectionSubQueryImpl(final T selectQuery) {
    setParent(selectQuery);
    this.selectionCore = new SelectionCoreImpl();
  }

  @Override
  public SelectionSubQueryImpl distinct() {
    selectionCore.distinct();
    return this;
  }

  @Override
  public SelectionSubQueryImpl as(final String aliasName) {
    selectionCore.as(aliasName);
    return this;
  }

  @Override
  public SelectionSubQueryImpl all() {
    selectionCore.all();
    return this;
  }

  @Override
  public SelectionSubQueryImpl countAll() {
    selectionCore.countAll();
    return this;
  }

  @Override
  public SelectionSubQueryImpl column(final String name) {
    selectionCore.column(name);
    return this;
  }

  @Override
  public SelectionSubQueryImpl regex(final String clause) {
    selectionCore.regex(clause);
    return this;
  }

  @Override
  public SelectionSubQueryImpl function(final String name, final Object... parameters) {
    selectionCore.function(name, parameters);
    return this;
  }

  @Override
  public SelectionSubQueryImpl raw(final String text) {
    selectionCore.raw(text);
    return this;
  }

  @Override
  public SelectionSubQueryImpl count(final Object column) {
    selectionCore.count(column);
    return this;
  }

  @Override
  public SelectionSubQueryImpl max(final Object column) {
    selectionCore.max(column);
    return this;
  }

  @Override
  public SelectionSubQueryImpl min(final Object column) {
    selectionCore.min(column);
    return this;
  }

  @Override
  public SelectionSubQueryImpl sum(final Object column) {
    selectionCore.sum(column);
    return this;
  }

  @Override
  public SelectionSubQueryImpl mean(final Object column) {
    selectionCore.mean(column);
    return this;
  }

  @Override
  public SelectionSubQueryImpl op(final OperationClause operationClause) {
    selectionCore.op(operationClause);
    return this;
  }

  @Override
  public SelectionSubQueryImpl op(final Object arg1, final String op, final Object arg2) {
    selectionCore.op(arg1, op, arg2);
    return this;
  }

  @Override
  public SelectionSubQueryImpl cop(final SimpleClause simpleClause) {
    selectionCore.cop(simpleClause);
    return this;
  }

  @Override
  public SelectionSubQueryImpl cop(final String column, final String op, final Object arg2) {
    selectionCore.cop(column, op, arg2);
    return this;
  }

  public SelectSubQueryImpl fromRaw(final String text) {
    return from(new RawFromClause(text));
  }

  public SelectSubQueryImpl from(final String[] tables) {
    if (tables == null) {
      throw new IllegalArgumentException("Tables names should be specified");
    }

    return from(new MultipleFromClause(Arrays.asList(tables)));
  }

  public SelectSubQueryImpl from(final String table) {
    return from(new SimpleFromClause(table));
  }

  private SelectSubQueryImpl from(final FromClause fromClause) {
    selectionCore.clearSelection();
    SelectSubQueryImpl subSelect =
        new SelectSubQueryImpl<>(fromClause, selectionCore.columns, selectionCore.isDistinct);
    subSelect.setParent(getParent());
    return subSelect;
  }

  public SelectionSubQueryImpl> fromSubQuery() {
    selectionCore.clearSelection();
    SelectSubQueryImpl selectSubQuery =
        new SelectSubQueryImpl<>(selectionCore.columns, selectionCore.isDistinct);
    selectSubQuery.setParent(this.getParent());
    SelectionSubQueryImpl> selectionSubQuery
      = new SelectionSubQueryImpl<>(selectSubQuery);
    return selectionSubQuery;
  }

  @Override
  public void setSubQuery(final QueryStringBuilder query) {
  }

  @Override
  public StringBuilder buildQueryString() {
    return null;
  }

  @Override
  public StringBuilder buildQueryString(final StringBuilder stringBuilder) {
    return null;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy