From 2766213e4336af0654d0eb7922c8a9ba43160135 Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Sat, 29 Apr 2023 15:16:50 +0800 Subject: [PATCH] =?UTF-8?q?isTrue=20=E5=92=8C=20isFalse=20=E7=9A=84=20cond?= =?UTF-8?q?itions=20=E5=8F=82=E6=95=B0=E5=85=81=E8=AE=B8=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zhouxy/plusone/commons/util/Assert.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 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 3bc0191..82d62c2 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/Assert.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/Assert.java @@ -9,31 +9,31 @@ import javax.annotation.Nullable; public class Assert { // isTrue - public static void isTrue(boolean conditions, Supplier e) throws E { - if (!conditions) { + public static void isTrue(@Nullable Boolean conditions, Supplier e) throws E { + if (!Boolean.TRUE.equals(conditions)) { throw e.get(); } } - public static void isTrue(boolean conditions, String errorMessage) { + public static void isTrue(@Nullable Boolean conditions, String errorMessage) { Assert.isTrue(conditions, () -> new IllegalArgumentException(errorMessage)); } - public static void isTrue(boolean conditions, String errorMessageTemplate, Object... args) { + public static void isTrue(@Nullable Boolean conditions, String errorMessageTemplate, Object... args) { Assert.isTrue(conditions, String.format(errorMessageTemplate, args)); } // isFalse - public static void isFalse(boolean conditions, Supplier e) throws E { - Assert.isTrue(!conditions, e); + public static void isFalse(@Nullable Boolean conditions, Supplier e) throws E { + Assert.isTrue(Boolean.FALSE.equals(conditions), e); } - public static void isFalse(boolean conditions, String errorMessage) { - Assert.isTrue(!conditions, () -> new IllegalArgumentException(errorMessage)); + public static void isFalse(@Nullable Boolean conditions, String errorMessage) { + Assert.isTrue(Boolean.FALSE.equals(conditions), () -> new IllegalArgumentException(errorMessage)); } - public static void isFalse(boolean conditions, String errorMessageTemplate, Object... args) { - Assert.isTrue(!conditions, String.format(errorMessageTemplate, args)); + public static void isFalse(@Nullable Boolean conditions, String errorMessageTemplate, Object... args) { + Assert.isTrue(Boolean.FALSE.equals(conditions), String.format(errorMessageTemplate, args)); } // between - int