添加 int、long、double 的数组的相关方法。

feature/net-util
ZhouXY108 2023-04-30 09:56:16 +08:00
parent 9b268b668e
commit 4d96cdf8ec
1 changed files with 78 additions and 1 deletions

View File

@ -151,8 +151,46 @@ public class Assert {
Assert.isTrue(MoreArrays.isEmpty(arr), errorMessageTemplate, args); Assert.isTrue(MoreArrays.isEmpty(arr), errorMessageTemplate, args);
} }
// isEmpty - int[]
public static <E extends Throwable> void isEmpty(@Nullable int[] arr, Supplier<E> e) throws E {
Assert.isTrue(MoreArrays.isEmpty(arr), e);
}
public static void isEmpty(@Nullable int[] arr, String errorMessage) {
Assert.isTrue(MoreArrays.isEmpty(arr), errorMessage);
}
public static void isEmpty(@Nullable int[] arr, String errorMessageTemplate, Object... args) {
Assert.isTrue(MoreArrays.isEmpty(arr), errorMessageTemplate, args);
}
// isEmpty - long[]
public static <E extends Throwable> void isEmpty(@Nullable long[] arr, Supplier<E> e) throws E {
Assert.isTrue(MoreArrays.isEmpty(arr), e);
}
public static void isEmpty(@Nullable long[] arr, String errorMessage) {
Assert.isTrue(MoreArrays.isEmpty(arr), errorMessage);
}
public static void isEmpty(@Nullable long[] arr, String errorMessageTemplate, Object... args) {
Assert.isTrue(MoreArrays.isEmpty(arr), errorMessageTemplate, args);
}
// isEmpty - double[]
public static <E extends Throwable> void isEmpty(@Nullable double[] arr, Supplier<E> e) throws E {
Assert.isTrue(MoreArrays.isEmpty(arr), e);
}
public static void isEmpty(@Nullable double[] arr, String errorMessage) {
Assert.isTrue(MoreArrays.isEmpty(arr), errorMessage);
}
public static void isEmpty(@Nullable double[] arr, String errorMessageTemplate, Object... args) {
Assert.isTrue(MoreArrays.isEmpty(arr), errorMessageTemplate, args);
}
// isNotEmpty - Array // isNotEmpty - Array
// TODO int[] long[] double[]
public static <T, E extends Throwable> void isNotEmpty(@Nullable T[] arr, Supplier<E> e) throws E { public static <T, E extends Throwable> void isNotEmpty(@Nullable T[] arr, Supplier<E> e) throws E {
Assert.isTrue(MoreArrays.isNotEmpty(arr), e); Assert.isTrue(MoreArrays.isNotEmpty(arr), e);
} }
@ -165,6 +203,45 @@ public class Assert {
Assert.isTrue(MoreArrays.isNotEmpty(arr), errorMessageTemplate, args); Assert.isTrue(MoreArrays.isNotEmpty(arr), errorMessageTemplate, args);
} }
// isNotEmpty - int[]
public static <E extends Throwable> void isNotEmpty(@Nullable int[] arr, Supplier<E> e) throws E {
Assert.isTrue(MoreArrays.isNotEmpty(arr), e);
}
public static void isNotEmpty(@Nullable int[] arr, String errorMessage) {
Assert.isTrue(MoreArrays.isNotEmpty(arr), errorMessage);
}
public static void isNotEmpty(@Nullable int[] arr, String errorMessageTemplate, Object... args) {
Assert.isTrue(MoreArrays.isNotEmpty(arr), errorMessageTemplate, args);
}
// isNotEmpty - long[]
public static <E extends Throwable> void isNotEmpty(@Nullable long[] arr, Supplier<E> e) throws E {
Assert.isTrue(MoreArrays.isNotEmpty(arr), e);
}
public static void isNotEmpty(@Nullable long[] arr, String errorMessage) {
Assert.isTrue(MoreArrays.isNotEmpty(arr), errorMessage);
}
public static void isNotEmpty(@Nullable long[] arr, String errorMessageTemplate, Object... args) {
Assert.isTrue(MoreArrays.isNotEmpty(arr), errorMessageTemplate, args);
}
// isNotEmpty - double[]
public static <E extends Throwable> void isNotEmpty(@Nullable double[] arr, Supplier<E> e) throws E {
Assert.isTrue(MoreArrays.isNotEmpty(arr), e);
}
public static void isNotEmpty(@Nullable double[] arr, String errorMessage) {
Assert.isTrue(MoreArrays.isNotEmpty(arr), errorMessage);
}
public static void isNotEmpty(@Nullable double[] arr, String errorMessageTemplate, Object... args) {
Assert.isTrue(MoreArrays.isNotEmpty(arr), errorMessageTemplate, args);
}
// isEmpty - String // isEmpty - String
public static <E extends Throwable> void isEmpty(@Nullable String str, Supplier<E> e) throws E { public static <E extends Throwable> void isEmpty(@Nullable String str, Supplier<E> e) throws E {
Assert.isTrue(Strings.isNullOrEmpty(str), e); Assert.isTrue(Strings.isNullOrEmpty(str), e);