diff options
author | 2024-11-16 01:18:20 +0000 | |
---|---|---|
committer | 2024-11-16 01:18:20 +0000 | |
commit | 057be0a6852481864888f90e37ade50a0a39f8b5 (patch) | |
tree | 568281e8d040dd97ec37e89d89af729832b59405 /ravenwood/runtime-common-src | |
parent | 1ce0ccf1ac9217b52971ccaf24ab89d437beb465 (diff) | |
parent | 121d051b25367340fe27a4f74cd1fac2f0d229fb (diff) |
Merge "Set package name via the build file, not via Config." into main
Diffstat (limited to 'ravenwood/runtime-common-src')
-rw-r--r-- | ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodCommonUtils.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodCommonUtils.java b/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodCommonUtils.java index 2bd079a9d135..2a04d4469ef4 100644 --- a/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodCommonUtils.java +++ b/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodCommonUtils.java @@ -312,4 +312,21 @@ public class RavenwoodCommonUtils { th.printStackTrace(writer); return stringWriter.toString(); } + + /** Same as {@link Integer#parseInt(String)} but accepts null and returns null. */ + @Nullable + public static Integer parseNullableInt(@Nullable String value) { + if (value == null) { + return null; + } + return Integer.parseInt(value); + } + + /** + * @return {@code value} if it's non-null. Otherwise, returns {@code def}. + */ + @Nullable + public static <T> T withDefault(@Nullable T value, @Nullable T def) { + return value != null ? value : def; + } } |