Internal refactoring to move version splitting to JavaVersion
This commit is contained in:
parent
5f72c77386
commit
966fbf05e2
|
@ -282,6 +282,10 @@ public enum JavaVersion {
|
|||
return v > 0 ? v : 99f;
|
||||
}
|
||||
|
||||
static String[] split(final String value) {
|
||||
return value.split(VERSION_SPLIT_REGEX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a float value from a String.
|
||||
*
|
||||
|
@ -293,7 +297,7 @@ public enum JavaVersion {
|
|||
if (!value.contains(".")) {
|
||||
return NumberUtils.toFloat(value, defaultReturnValue);
|
||||
}
|
||||
final String[] toParse = value.split("\\.");
|
||||
final String[] toParse = split(value);
|
||||
if (toParse.length >= 2) {
|
||||
return NumberUtils.toFloat(toParse[0] + '.' + toParse[1], defaultReturnValue);
|
||||
}
|
||||
|
@ -310,6 +314,11 @@ public enum JavaVersion {
|
|||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The regex to split version strings.
|
||||
*/
|
||||
private static final String VERSION_SPLIT_REGEX = "\\.";
|
||||
|
||||
/**
|
||||
* Constructs a new instance.
|
||||
*
|
||||
|
|
|
@ -34,11 +34,6 @@ import java.io.File;
|
|||
*/
|
||||
public class SystemUtils {
|
||||
|
||||
/**
|
||||
* The regex to split version strings.
|
||||
*/
|
||||
private static final String VERSION_SPLIT_REGEX = "\\.";
|
||||
|
||||
/**
|
||||
* The prefix String for all Windows OS.
|
||||
*/
|
||||
|
@ -2155,8 +2150,8 @@ public class SystemUtils {
|
|||
}
|
||||
// Compare parts of the version string instead of using String.startsWith(String) because otherwise
|
||||
// osVersionPrefix 10.1 would also match osVersion 10.10
|
||||
final String[] versionPrefixParts = osVersionPrefix.split(VERSION_SPLIT_REGEX);
|
||||
final String[] versionParts = osVersion.split(VERSION_SPLIT_REGEX);
|
||||
final String[] versionPrefixParts = JavaVersion.split(osVersionPrefix);
|
||||
final String[] versionParts = JavaVersion.split(osVersion);
|
||||
for (int i = 0; i < Math.min(versionPrefixParts.length, versionParts.length); i++) {
|
||||
if (!versionPrefixParts[i].equals(versionParts[i])) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue