diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/OptionalUtil.java b/src/main/java/xyz/zhouxy/plusone/commons/util/OptionalUtil.java index 05808a7..4c852fa 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/OptionalUtil.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/OptionalUtil.java @@ -134,6 +134,21 @@ public class OptionalUtil { return optionalObj.orElse(null); } + @Beta + public static Integer toInteger(OptionalInt optionalObj) { + return optionalObj.isPresent() ? optionalObj.getAsInt() : null; + } + + @Beta + public static Long toLong(OptionalLong optionalObj) { + return optionalObj.isPresent() ? optionalObj.getAsLong() : null; + } + + @Beta + public static Double toDouble(OptionalDouble optionalObj) { + return optionalObj.isPresent() ? optionalObj.getAsDouble() : null; + } + private OptionalUtil() { throw new IllegalStateException("Utility class"); }