diff options
-rw-r--r-- | src/changes/changes.xml | 1 | ||||
-rw-r--r-- | src/main/java/org/apache/commons/lang3/SystemUtils.java | 13 | ||||
-rw-r--r-- | src/test/java/org/apache/commons/lang3/SystemUtilsTest.java | 10 |
3 files changed, 24 insertions, 0 deletions
diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 129bb71ea..9d4e1ff0f 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -67,6 +67,7 @@ The <action> type attribute can be add,update,fix,remove. <action type="add" dev="ggregory" due-to="Gary Gregory">Add MethodUtils.getMethodObject(Class, String, Class...).</action> <action issue="LANG-1733" type="add" dev="ggregory" due-to="Jongjin Bae, Gary Gregory">Add null-safe Consumers.accept() and Functions.apply() #1215.</action> <action type="add" dev="ggregory" due-to="Gary Gregory">Add SystemUtils.IS_OS_ANDROID.</action> + <action type="add" dev="ggregory" due-to="Gary Gregory">Add SystemUtils.IS_OS_MAC_OSX_SONOMA.</action> <!-- FIX --> <action type="fix" dev="ggregory" due-to="Miklós Karakó, Gary Gregory">Improve Javadoc in ExceptionUtils #1136.</action> <action type="fix" dev="ggregory" due-to="Saiharshith Karuneegar Ramesh, Gary Gregory">Fixed two non-deterministic tests in EnumUtilsTest.java #1131.</action> diff --git a/src/main/java/org/apache/commons/lang3/SystemUtils.java b/src/main/java/org/apache/commons/lang3/SystemUtils.java index 70c9a8d2c..e712aa56f 100644 --- a/src/main/java/org/apache/commons/lang3/SystemUtils.java +++ b/src/main/java/org/apache/commons/lang3/SystemUtils.java @@ -1507,6 +1507,19 @@ public class SystemUtils { public static final boolean IS_OS_MAC_OSX_VENTURA = getOsMatches("Mac OS X", "13"); /** + * Is {@code true} if this is macOS X Sonoma. + * + * <p> + * The field will return {@code false} if {@code OS_NAME} is {@code null}. + * </p> + * <p> + * This value is initialized when the class is loaded. + * </p> + * @since 3.15.0 + */ + public static final boolean IS_OS_MAC_OSX_SONOMA = getOsMatches("Mac OS X", "14"); + + /** * Is {@code true} if this is FreeBSD. * * <p> diff --git a/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java b/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java index 8618d6744..ec4b04807 100644 --- a/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java @@ -168,6 +168,16 @@ public class SystemUtilsTest extends AbstractLangTest { assertTrue(SystemUtils.IS_OS_UNIX); assertFalse(SystemUtils.IS_OS_ANDROID); assertFalse(SystemUtils.IS_OS_WINDOWS); + final boolean macOsValues[] = { SystemUtils.IS_OS_MAC_OSX_BIG_SUR, SystemUtils.IS_OS_MAC_OSX_CATALINA, SystemUtils.IS_OS_MAC_OSX_CHEETAH, + SystemUtils.IS_OS_MAC_OSX_EL_CAPITAN, SystemUtils.IS_OS_MAC_OSX_HIGH_SIERRA, SystemUtils.IS_OS_MAC_OSX_JAGUAR, + SystemUtils.IS_OS_MAC_OSX_LEOPARD, SystemUtils.IS_OS_MAC_OSX_LION, SystemUtils.IS_OS_MAC_OSX_MAVERICKS, SystemUtils.IS_OS_MAC_OSX_MOJAVE, + SystemUtils.IS_OS_MAC_OSX_MONTEREY, SystemUtils.IS_OS_MAC_OSX_MOUNTAIN_LION, SystemUtils.IS_OS_MAC_OSX_PANTHER, + SystemUtils.IS_OS_MAC_OSX_PUMA, SystemUtils.IS_OS_MAC_OSX_SIERRA, SystemUtils.IS_OS_MAC_OSX_SNOW_LEOPARD, SystemUtils.IS_OS_MAC_OSX_SONOMA, + SystemUtils.IS_OS_MAC_OSX_TIGER, SystemUtils.IS_OS_MAC_OSX_VENTURA, SystemUtils.IS_OS_MAC_OSX_YOSEMITE }; + if (BooleanUtils.or(macOsValues)) { + // If one is true, then only one should be true. + assertTrue(BooleanUtils.xor(macOsValues)); + } } else if (osName.startsWith("OS/2")) { assertTrue(SystemUtils.IS_OS_OS2); assertFalse(SystemUtils.IS_OS_UNIX); |