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

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

package org.influxdb.querybuilder;

import java.util.ArrayList;
import java.util.List;
import org.influxdb.querybuilder.clauses.AndConjunction;
import org.influxdb.querybuilder.clauses.Clause;
import org.influxdb.querybuilder.clauses.ConjunctionClause;
import org.influxdb.querybuilder.clauses.NestedClause;
import org.influxdb.querybuilder.clauses.OrConjunction;

public class WhereNested {

  private final List clauses = new ArrayList<>();
  private final boolean orConjunction;
  private final T where;

  WhereNested(final T where, final boolean orConjunction) {
    this.where = where;
    this.orConjunction = orConjunction;
  }

  public WhereNested and(final Clause clause) {
    clauses.add(new AndConjunction(clause));
    return this;
  }

  public WhereNested or(final Clause clause) {
    clauses.add(new OrConjunction(clause));
    return this;
  }

  public T close() {
    if (orConjunction) {
      where.or(new NestedClause(clauses));
    } else {
      where.and(new NestedClause(clauses));
    }

    return where;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy