From 404188abda7505942d688165492c005692b09ccf Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Sun, 30 Apr 2023 11:11:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B9=E6=B3=95=EF=BC=8C?= =?UTF-8?q?=E5=87=8F=E5=B0=91=E8=B0=83=E7=94=A8=E5=A0=86=E6=A0=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/xyz/zhouxy/plusone/commons/util/Assert.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/Assert.java b/src/main/java/xyz/zhouxy/plusone/commons/util/Assert.java index 9a1a441..3fb524b 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/Assert.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/Assert.java @@ -270,15 +270,21 @@ public class Assert { // hasText - String public static void hasText(@Nullable String str, Supplier e) throws E { - Assert.isTrue(MoreStrings.hasText(str), e); + if (!MoreStrings.hasText(str)) { + throw e.get(); + } } public static void hasText(@Nullable String str, String errorMessage) { - Assert.isTrue(MoreStrings.hasText(str), errorMessage); + if (!MoreStrings.hasText(str)) { + throw new IllegalArgumentException(errorMessage); + } } public static void hasText(@Nullable String str, String errorMessageTemplate, Object... args) { - Assert.isTrue(MoreStrings.hasText(str), errorMessageTemplate, args); + if (!MoreStrings.hasText(str)) { + throw new IllegalArgumentException(String.format(errorMessageTemplate, args)); + } } // private constructor