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 d7f0bf4..ee35e8c 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/Assert.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/Assert.java @@ -88,7 +88,7 @@ public class Assert { Assert.isTrue(Objects.nonNull(value), errorMessageTemplate, args); } - // isEmpty + // isEmpty - Collection public static void isEmpty(@Nullable Collection collection, Supplier e) throws E { Assert.isTrue((collection == null || collection.isEmpty()), e); } @@ -101,7 +101,7 @@ public class Assert { Assert.isTrue((collection == null || collection.isEmpty()), errorMessageTemplate, args); } - // isNotEmpty + // isNotEmpty - Collection public static void isNotEmpty(@Nullable Collection collection, Supplier e) throws E { Assert.isFalse((collection == null || collection.isEmpty()), e); } @@ -114,6 +114,58 @@ public class Assert { Assert.isFalse((collection == null || collection.isEmpty()), errorMessageTemplate, args); } + // isEmpty - Array + public static void isEmpty(@Nullable T[] arr, Supplier e) throws E { + Assert.isTrue((arr == null || arr.length == 0), e); + } + + public static void isEmpty(@Nullable T[] arr, String errorMessage) { + Assert.isTrue((arr == null || arr.length == 0), errorMessage); + } + + public static void isEmpty(@Nullable T[] arr, String errorMessageTemplate, Object... args) { + Assert.isTrue((arr == null || arr.length == 0), errorMessageTemplate, args); + } + + // isNotEmpty - Collection + public static void isNotEmpty(@Nullable T[] arr, Supplier e) throws E { + Assert.isFalse((arr == null || arr.length == 0), e); + } + + public static void isNotEmpty(@Nullable T[] arr, String errorMessage) { + Assert.isFalse((arr == null || arr.length == 0), errorMessage); + } + + public static void isNotEmpty(@Nullable T[] arr, String errorMessageTemplate, Object... args) { + Assert.isFalse((arr == null || arr.length == 0), errorMessageTemplate, args); + } + + // isEmpty - Array + public static void isEmpty(@Nullable String arr, Supplier e) throws E { + Assert.isTrue((arr == null || arr.length() == 0), e); + } + + public static void isEmpty(@Nullable String arr, String errorMessage) { + Assert.isTrue((arr == null || arr.length() == 0), errorMessage); + } + + public static void isEmpty(@Nullable String arr, String errorMessageTemplate, Object... args) { + Assert.isTrue((arr == null || arr.length() == 0), errorMessageTemplate, args); + } + + // isNotEmpty - Collection + public static void isNotEmpty(@Nullable String arr, Supplier e) throws E { + Assert.isFalse((arr == null || arr.length() == 0), e); + } + + public static void isNotEmpty(@Nullable String arr, String errorMessage) { + Assert.isFalse((arr == null || arr.length() == 0), errorMessage); + } + + public static void isNotEmpty(@Nullable String arr, String errorMessageTemplate, Object... args) { + Assert.isFalse((arr == null || arr.length() == 0), errorMessageTemplate, args); + } + // private consrtuctor private Assert() { throw new IllegalStateException("Utility class");