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

net.quasardb.qdb.ts.QueryBuilder Maven / Gradle / Ivy

Go to download

API for the JNI components of the QuasarDB API for Java. Should not be included directly.

There is a newer version: 3.14.1
Show newest version
package net.quasardb.qdb.ts;

import java.util.StringJoiner;

/**
 * Utility class with functions that make it easier to construct
 * a query.
 */
public final class QueryBuilder {
    private StringJoiner query;

    public QueryBuilder() {
        this.query = new StringJoiner(" ");
    }

    private QueryBuilder(StringJoiner query) {
        this.query = query;
    }

    /**
     * Adds plain java string to query.
     */
    public QueryBuilder add(String str) {
        return new QueryBuilder(this.query.add(str));
    }

    /**
     * Adds clause that limits a query's results to a
     * timerange.
     */
    public QueryBuilder in(TimeRange range) {
        return
            add("in range (")
            .add(range.getBegin().asInstant().toString())
            .add(",")
            .add(range.getEnd().asInstant().toString())
            .add(")");
    }

    public Query asQuery() {
        return Query.of(this.toString());
    }

    public String toString() {
        return this.query.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy