pbom-升级版本号获取
This commit is contained in:
parent
7e6aafd545
commit
3f6cde7e7a
|
|
@ -122,4 +122,42 @@ public class VersionUtil {
|
|||
return Integer.compare(split1.length, split2.length);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取PBOM 升级版本号(PBOM升级版本号规则)
|
||||
* @param version
|
||||
* @return
|
||||
*/
|
||||
public static String getPBomUpgradNextVersion(String version) {
|
||||
if (version == null || version.isEmpty()) {
|
||||
throw new IllegalArgumentException("输入版本号不能为空");
|
||||
}
|
||||
char lastChar = version.charAt(version.length() - 1);
|
||||
boolean isLetter = Character.isLetter(lastChar);
|
||||
if (!isLetter) {
|
||||
return version + "a";
|
||||
} else {
|
||||
int lastCharIndex = version.length() - 1;
|
||||
char newLastChar = (char) (lastChar + 1);
|
||||
|
||||
if (newLastChar > 'z') {
|
||||
// Handle case where the last character is 'z'
|
||||
StringBuilder sb = new StringBuilder(version.substring(0, lastCharIndex));
|
||||
sb.append("a").append('a');
|
||||
return sb.toString();
|
||||
} else {
|
||||
return version.substring(0, lastCharIndex) + newLastChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getNextLetter(char currentLetter) {
|
||||
char nextLetter = (char) (currentLetter + 1);
|
||||
if (nextLetter > 'z') {
|
||||
return "a" + getNextLetter('a');
|
||||
} else {
|
||||
return "" + nextLetter;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue