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

ru.yandex.clickhouse.util.ClickHouseVersionNumberUtil Maven / Gradle / Ivy

There is a newer version: 0.3.2
Show newest version
package ru.yandex.clickhouse.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Very simple version number parser. It is only needed for ClickHouse driver
 * and database version numbers
 */
public final class ClickHouseVersionNumberUtil {

    private static final Pattern VERSION_NUMBER_PATTERN =
        Pattern.compile("^\\s*(\\d+)\\.(\\d+).*");

    public static int getMajorVersion(String versionNumber) {
        Matcher m = VERSION_NUMBER_PATTERN.matcher(versionNumber);
        return m.matches() ? Integer.parseInt(m.group(1)) : 0;
    }

    public static int getMinorVersion(String versionNumber) {
        Matcher m = VERSION_NUMBER_PATTERN.matcher(versionNumber);
        return m.matches() ? Integer.parseInt(m.group(2)) : 0;
    }

    private ClickHouseVersionNumberUtil() { /* do not instantiate util */ }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy