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

com.aeontronix.enhancedmule.tools.util.VersionUtils Maven / Gradle / Ivy

There is a newer version: 2.0.0-alpha4
Show newest version
/*
 * Copyright (c) Aeontronix 2019
 */

package com.aeontronix.enhancedmule.tools.util;

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

public class VersionUtils {
    public static final Pattern MAJORVERSION_REGEX = Pattern.compile("(\\d*)\\..*");

    public static int getMajorVersion(String version) {
        Matcher m = MAJORVERSION_REGEX.matcher(version);
        try {
            if (m.find()) {
                return Integer.parseInt(m.group(1));
            }
        } catch (NumberFormatException e) {
            //
        }
        throw new IllegalArgumentException("Invalid version: " + version);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy