修改方法,减少调用堆栈。

feature/net-util
ZhouXY108 2023-04-30 11:11:44 +08:00
parent 9d6f6edacb
commit 404188abda
1 changed files with 9 additions and 3 deletions

View File

@ -270,15 +270,21 @@ public class Assert {
// hasText - String // hasText - String
public static <E extends Throwable> void hasText(@Nullable String str, Supplier<E> e) throws E { public static <E extends Throwable> void hasText(@Nullable String str, Supplier<E> 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) { 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) { 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 // private constructor