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

ru.yandex.clickhouse.ConfigurableApi Maven / Gradle / Ivy

There is a newer version: 0.7.1-patch1
Show newest version
package ru.yandex.clickhouse;

import ru.yandex.clickhouse.settings.ClickHouseQueryParam;

import java.util.*;

@SuppressWarnings("unchecked")
class ConfigurableApi {

    protected final ClickHouseStatementImpl statement;
    private Map additionalDBParams = new HashMap();
    private Map additionalRequestParams = new HashMap();

    ConfigurableApi(ClickHouseStatementImpl statement) {
        this.statement = statement;
    }

    Map getRequestParams() {
        return additionalRequestParams;
    }

    Map getAdditionalDBParams() {
        return additionalDBParams;
    }

    public T addDbParam(ClickHouseQueryParam param, String value) {
        additionalDBParams.put(param, value);
        return (T) this;
    }

    public T removeDbParam(ClickHouseQueryParam param) {
        additionalDBParams.remove(param);
        return (T) this;
    }

    public T withDbParams(Map dbParams) {
        this.additionalDBParams = new HashMap();
        if (null != dbParams) {
            additionalDBParams.putAll(dbParams);
        }
        return (T) this;
    }

    public T options(Map params) {
        additionalRequestParams = new HashMap();
        if (null != params) {
            additionalRequestParams.putAll(params);
        }
        return (T) this;
    }

    public T option(String key, String value) {
        additionalRequestParams.put(key, value);
        return (T) this;
    }

    public T removeOption(String key) {
        additionalRequestParams.remove(key);
        return (T) this;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy