From 1ade08783f123d987bb84ea61888423bf3e92dc3 Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Mon, 14 Oct 2024 16:35:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/xyz/zhouxy/plusone/commons/util/OptionalTools.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/OptionalTools.java b/src/main/java/xyz/zhouxy/plusone/commons/util/OptionalTools.java index b24787f..288ac77 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/OptionalTools.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/OptionalTools.java @@ -64,7 +64,7 @@ public class OptionalTools { * @return {@link OptionalInt} 实例 */ public static OptionalInt toOptionalInt(Optional optionalObj) { - return optionalOf(optionalObj.orElse(null)); + return optionalObj.isPresent() ? OptionalInt.of(optionalObj.get()) : OptionalInt.empty(); } /** @@ -91,7 +91,7 @@ public class OptionalTools { * @return {@link OptionalLong} 实例 */ public static OptionalLong toOptionalLong(Optional optionalObj) { - return optionalOf(optionalObj.orElse(null)); + return optionalObj.isPresent() ? OptionalLong.of(optionalObj.get()) : OptionalLong.empty(); } /** @@ -118,7 +118,7 @@ public class OptionalTools { * @return {@link OptionalDouble} 实例 */ public static OptionalDouble toOptionalDouble(Optional optionalObj) { - return optionalOf(optionalObj.orElse(null)); + return optionalObj.isPresent() ? OptionalDouble.of(optionalObj.get()) : OptionalDouble.empty(); } /**