[LANG-1512] Add IS_JAVA_14 and IS_JAVA_15 to

org.apache.commons.lang3.SystemUtils.
This commit is contained in:
Gary Gregory 2020-01-06 11:39:33 -05:00
parent 365f73c455
commit 259ac721ce
3 changed files with 71 additions and 0 deletions

View File

@ -93,6 +93,7 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="LANG-1508" type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.lang3.SystemUtils.getUserName().</action>
<action issue="LANG-1509" type="add" dev="ggregory" due-to="Gary Gregory">Add ObjectToStringComparator. #483.</action>
<action issue="LANG-1510" type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.lang3.arch.Processor.Arch.getLabel().</action>
<action issue="LANG-1512" type="add" dev="ggregory" due-to="Gary Gregory">Add IS_JAVA_14 and IS_JAVA_15 to org.apache.commons.lang3.SystemUtils.</action>
</release>
<release version="3.9" date="2019-04-09" description="New features and bug fixes. Requires Java 8, supports Java 9, 10, 11.">

View File

@ -1026,6 +1026,30 @@ public class SystemUtils {
*/
public static final boolean IS_JAVA_13 = getJavaVersionMatches("13");
/**
* <p>
* Is {@code true} if this is Java version 14 (also 14.x versions).
* </p>
* <p>
* The field will return {@code false} if {@link #JAVA_VERSION} is {@code null}.
* </p>
*
* @since 3.10
*/
public static final boolean IS_JAVA_14 = getJavaVersionMatches("14");
/**
* <p>
* Is {@code true} if this is Java version 15 (also 15.x versions).
* </p>
* <p>
* The field will return {@code false} if {@link #JAVA_VERSION} is {@code null}.
* </p>
*
* @since 3.10
*/
public static final boolean IS_JAVA_15 = getJavaVersionMatches("15");
// Operating system checks
// -----------------------------------------------------------------------
// These MUST be declared after those above as they depend on the

View File

@ -155,6 +155,8 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_11);
assertFalse(SystemUtils.IS_JAVA_12);
assertFalse(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
} else if (javaVersion.startsWith("1.8")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@ -170,6 +172,8 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_11);
assertFalse(SystemUtils.IS_JAVA_12);
assertFalse(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
} else if (javaVersion.startsWith("9")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@ -185,6 +189,8 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_11);
assertFalse(SystemUtils.IS_JAVA_12);
assertFalse(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
} else if (javaVersion.startsWith("10")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@ -200,6 +206,8 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_11);
assertFalse(SystemUtils.IS_JAVA_12);
assertFalse(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
} else if (javaVersion.startsWith("11")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@ -215,6 +223,8 @@ public class SystemUtilsTest {
assertTrue(SystemUtils.IS_JAVA_11);
assertFalse(SystemUtils.IS_JAVA_12);
assertFalse(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
} else if (javaVersion.startsWith("12")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@ -245,6 +255,42 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_11);
assertFalse(SystemUtils.IS_JAVA_12);
assertTrue(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
} else if (javaVersion.startsWith("14")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
assertFalse(SystemUtils.IS_JAVA_1_3);
assertFalse(SystemUtils.IS_JAVA_1_4);
assertFalse(SystemUtils.IS_JAVA_1_5);
assertFalse(SystemUtils.IS_JAVA_1_6);
assertFalse(SystemUtils.IS_JAVA_1_7);
assertFalse(SystemUtils.IS_JAVA_1_8);
assertFalse(SystemUtils.IS_JAVA_1_9);
assertFalse(SystemUtils.IS_JAVA_9);
assertFalse(SystemUtils.IS_JAVA_10);
assertFalse(SystemUtils.IS_JAVA_11);
assertFalse(SystemUtils.IS_JAVA_12);
assertFalse(SystemUtils.IS_JAVA_13);
assertTrue(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
} else if (javaVersion.startsWith("15")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
assertFalse(SystemUtils.IS_JAVA_1_3);
assertFalse(SystemUtils.IS_JAVA_1_4);
assertFalse(SystemUtils.IS_JAVA_1_5);
assertFalse(SystemUtils.IS_JAVA_1_6);
assertFalse(SystemUtils.IS_JAVA_1_7);
assertFalse(SystemUtils.IS_JAVA_1_8);
assertFalse(SystemUtils.IS_JAVA_1_9);
assertFalse(SystemUtils.IS_JAVA_9);
assertFalse(SystemUtils.IS_JAVA_10);
assertFalse(SystemUtils.IS_JAVA_11);
assertFalse(SystemUtils.IS_JAVA_12);
assertFalse(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertTrue(SystemUtils.IS_JAVA_15);
} else {
System.out.println("Can't test IS_JAVA value: " + javaVersion);
}