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

com.github.ngeor.yak4j.SemVer Maven / Gradle / Ivy

There is a newer version: 0.13.1
Show newest version
package com.github.ngeor.yak4j;

import java.util.Arrays;
import java.util.List;

/**
 * Helps with semantic versioning.
 */
public class SemVer {
    /**
     * Gets the allowed next versions after the given version.
     * @param version The version.
     * @return The allowed next versions.
     */
    List allowedVersions(String version) {
        String[] split = version.split("\\.");
        return Arrays.asList(
            patch(split),
            minor(split),
            major(split)
        );
    }

    private String patch(String[] split) {
        return split[0] + "." + split[1] + "." + (Integer.parseInt(split[2]) + 1);
    }

    private String minor(String[] split) {
        return split[0] + "." + (Integer.parseInt(split[1]) + 1) + ".0";
    }

    private String major(String[] split) {
        return (Integer.parseInt(split[0]) + 1) + ".0.0";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy