com.github.ngeor.yak4j.SemVer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yak4j-bitbucket-maven-plugin Show documentation
Show all versions of yak4j-bitbucket-maven-plugin Show documentation
yak shaving for Java: A Maven plugin which can create Bitbucket tags
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";
}
}