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

io.nosqlbench.engine.api.util.AdaptersApiVersionInfo Maven / Gradle / Ivy

/*
 * Copyright (c) 2022 nosqlbench
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.nosqlbench.engine.api.util;

import io.nosqlbench.api.errors.OpConfigError;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.regex.Pattern;

public class AdaptersApiVersionInfo {

    private final Properties versionProperties = new Properties();

    public AdaptersApiVersionInfo() {
        InputStream versionStream = getClass().getResourceAsStream("/version.properties");
        try {
            versionProperties.load(versionStream);
        } catch (IOException e) {
            throw new RuntimeException("unable to read version properties:" + e);
        }
    }

    public String getVersion() {
        return versionProperties.getProperty("version");
    }

    public String getArtifactId() {
        return versionProperties.getProperty("artifactId");
    }

    public String getGroupId() {
        return versionProperties.getProperty("groupId");
    }

    public String getArtifactCoordinates() {
        return "\n" +
                " " + getGroupId() + "\n" +
                " "+ getArtifactId() + "\n" +
                " " + getVersion() + "\n" +
                "";
    }

    public void assertNewer(String min_version) {
        String[] min_components = min_version.split("\\.|-|_");
        String[] current_components = getVersion().split("\\.|-|_");
        for (int i = 0; i < min_components.length; i++) {
            String minField = min_components[i];
            String currentField = current_components[i];
            if (minField.matches("\\d+")) {
                if (currentField.matches("\\d+")) {
                    if (Integer.parseInt(currentField)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy