2023-05-13 12:53:57 +08:00
|
|
|
/*
|
|
|
|
|
* Copyright 2022-2023 the original author or authors.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2023-04-21 01:46:46 +08:00
|
|
|
package xyz.zhouxy.plusone.commons.util;
|
|
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
|
2023-05-08 21:56:45 +08:00
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2023-04-29 15:35:34 +08:00
|
|
|
|
2023-04-21 01:46:46 +08:00
|
|
|
public class Assert {
|
|
|
|
|
|
|
|
|
|
// isTrue
|
2023-04-30 22:11:52 +08:00
|
|
|
public static <E extends Throwable> void isTrue(@Nullable Boolean condition, Supplier<E> e) throws E {
|
|
|
|
|
if (!Boolean.TRUE.equals(condition)) {
|
2023-04-21 01:46:46 +08:00
|
|
|
throw e.get();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-30 22:11:52 +08:00
|
|
|
public static void isTrue(@Nullable Boolean condition) {
|
|
|
|
|
if (!Boolean.TRUE.equals(condition)) {
|
|
|
|
|
throw new IllegalArgumentException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void isTrue(@Nullable Boolean condition, String errorMessage) {
|
|
|
|
|
if (!Boolean.TRUE.equals(condition)) {
|
2023-04-29 15:54:00 +08:00
|
|
|
throw new IllegalArgumentException(errorMessage);
|
|
|
|
|
}
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-30 22:11:52 +08:00
|
|
|
public static void isTrue(@Nullable Boolean condition, String errorMessageTemplate, Object... args) {
|
|
|
|
|
if (!Boolean.TRUE.equals(condition)) {
|
2023-04-29 15:54:00 +08:00
|
|
|
throw new IllegalArgumentException(String.format(errorMessageTemplate, args));
|
|
|
|
|
}
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// isFalse
|
2023-04-30 22:11:52 +08:00
|
|
|
public static <E extends Throwable> void isFalse(@Nullable Boolean condition, Supplier<E> e) throws E {
|
|
|
|
|
if (!Boolean.FALSE.equals(condition)) {
|
2023-04-29 15:54:00 +08:00
|
|
|
throw e.get();
|
|
|
|
|
}
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-30 22:11:52 +08:00
|
|
|
public static void isFalse(@Nullable Boolean condition) {
|
|
|
|
|
if (!Boolean.FALSE.equals(condition)) {
|
|
|
|
|
throw new IllegalArgumentException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void isFalse(@Nullable Boolean condition, String errorMessage) {
|
|
|
|
|
if (!Boolean.FALSE.equals(condition)) {
|
2023-04-29 15:54:00 +08:00
|
|
|
throw new IllegalArgumentException(errorMessage);
|
|
|
|
|
}
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-30 22:11:52 +08:00
|
|
|
public static void isFalse(@Nullable Boolean condition, String errorMessageTemplate, Object... args) {
|
|
|
|
|
if (!Boolean.FALSE.equals(condition)) {
|
2023-04-29 15:54:00 +08:00
|
|
|
throw new IllegalArgumentException(String.format(errorMessageTemplate, args));
|
|
|
|
|
}
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// between - int
|
2023-04-29 15:54:00 +08:00
|
|
|
private static boolean between(int value, int min, int max) {
|
|
|
|
|
return value >= min && value < max;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-21 01:46:46 +08:00
|
|
|
public static <E extends Throwable> void between(int value, int min, int max, Supplier<E> e) throws E {
|
2023-04-29 15:54:00 +08:00
|
|
|
Assert.isTrue(between(value, min, max), e);
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void between(int value, int min, int max, String errorMessage) {
|
2023-04-29 15:54:00 +08:00
|
|
|
Assert.isTrue(between(value, min, max), errorMessage);
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void between(int value, int min, int max, String errorMessageTemplate, Object... args) {
|
2023-04-29 15:54:00 +08:00
|
|
|
Assert.isTrue(between(value, min, max), errorMessageTemplate, args);
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// between - long
|
2023-04-29 15:54:00 +08:00
|
|
|
private static boolean between(long value, long min, long max) {
|
|
|
|
|
return value >= min && value < max;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-21 01:46:46 +08:00
|
|
|
public static <E extends Throwable> void between(long value, long min, long max, Supplier<E> e) throws E {
|
2023-04-29 15:54:00 +08:00
|
|
|
Assert.isTrue(between(value, min, max), e);
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void between(long value, long min, long max, String errorMessage) {
|
2023-04-29 15:54:00 +08:00
|
|
|
Assert.isTrue(between(value, min, max), errorMessage);
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void between(long value, long min, long max, String errorMessageTemplate, Object... args) {
|
2023-04-29 15:54:00 +08:00
|
|
|
Assert.isTrue(between(value, min, max), errorMessageTemplate, args);
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// between - double
|
2023-04-29 15:54:00 +08:00
|
|
|
private static boolean between(double value, double min, double max) {
|
|
|
|
|
return value >= min && value < max;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-21 01:46:46 +08:00
|
|
|
public static <E extends Throwable> void between(double value, double min, double max, Supplier<E> e) throws E {
|
2023-04-29 15:54:00 +08:00
|
|
|
Assert.isTrue(between(value, min, max), e);
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void between(double value, double min, double max, String errorMessage) {
|
2023-04-29 15:54:00 +08:00
|
|
|
Assert.isTrue(between(value, min, max), errorMessage);
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void between(double value, double min, double max, String errorMessageTemplate, Object... args) {
|
2023-04-29 15:54:00 +08:00
|
|
|
Assert.isTrue(between(value, min, max), errorMessageTemplate, args);
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// notNull
|
|
|
|
|
public static <E extends Throwable> void notNull(Object value, Supplier<E> e) throws E {
|
|
|
|
|
Assert.isTrue(Objects.nonNull(value), e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static <E extends Throwable> void notNull(Object value, String errorMessage) throws E {
|
|
|
|
|
Assert.isTrue(Objects.nonNull(value), errorMessage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void notNull(Object value, String errorMessageTemplate, Object... args) {
|
|
|
|
|
Assert.isTrue(Objects.nonNull(value), errorMessageTemplate, args);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-21 03:21:21 +08:00
|
|
|
// isEmpty - Collection
|
2023-04-29 18:38:14 +08:00
|
|
|
public static <E extends Throwable> void isEmpty(@Nullable Collection<?> collection, Supplier<E> e) throws E {
|
|
|
|
|
Assert.isTrue(MoreCollections.isEmpty(collection), e);
|
2023-04-29 15:54:00 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-29 18:38:14 +08:00
|
|
|
public static void isEmpty(@Nullable Collection<?> collection, String errorMessage) {
|
|
|
|
|
Assert.isTrue(MoreCollections.isEmpty(collection), errorMessage);
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-29 18:38:14 +08:00
|
|
|
public static void isEmpty(@Nullable Collection<?> collection, String errorMessageTemplate, Object... args) {
|
|
|
|
|
Assert.isTrue(MoreCollections.isEmpty(collection), errorMessageTemplate, args);
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-21 03:21:21 +08:00
|
|
|
// isNotEmpty - Collection
|
2023-04-29 18:38:14 +08:00
|
|
|
public static <E extends Throwable> void isNotEmpty(@Nullable Collection<?> collection, Supplier<E> e) throws E {
|
|
|
|
|
Assert.isTrue(MoreCollections.isNotEmpty(collection), e);
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-29 18:38:14 +08:00
|
|
|
public static void isNotEmpty(@Nullable Collection<?> collection, String errorMessage) {
|
|
|
|
|
Assert.isTrue(MoreCollections.isNotEmpty(collection), errorMessage);
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-29 18:38:14 +08:00
|
|
|
public static void isNotEmpty(@Nullable Collection<?> collection, String errorMessageTemplate, Object... args) {
|
|
|
|
|
Assert.isTrue(MoreCollections.isNotEmpty(collection), errorMessageTemplate, args);
|
2023-04-21 01:46:46 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-21 03:21:21 +08:00
|
|
|
// isEmpty - Array
|
|
|
|
|
public static <T, E extends Throwable> void isEmpty(@Nullable T[] arr, Supplier<E> e) throws E {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isEmpty(arr), e);
|
2023-04-21 03:21:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static <T> void isEmpty(@Nullable T[] arr, String errorMessage) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isEmpty(arr), errorMessage);
|
2023-04-21 03:21:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static <T> void isEmpty(@Nullable T[] arr, String errorMessageTemplate, Object... args) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isEmpty(arr), errorMessageTemplate, args);
|
2023-04-21 03:21:21 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-30 09:56:16 +08:00
|
|
|
// isEmpty - int[]
|
|
|
|
|
public static <E extends Throwable> void isEmpty(@Nullable int[] arr, Supplier<E> e) throws E {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isEmpty(arr), e);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void isEmpty(@Nullable int[] arr, String errorMessage) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isEmpty(arr), errorMessage);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void isEmpty(@Nullable int[] arr, String errorMessageTemplate, Object... args) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isEmpty(arr), errorMessageTemplate, args);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// isEmpty - long[]
|
|
|
|
|
public static <E extends Throwable> void isEmpty(@Nullable long[] arr, Supplier<E> e) throws E {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isEmpty(arr), e);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void isEmpty(@Nullable long[] arr, String errorMessage) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isEmpty(arr), errorMessage);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void isEmpty(@Nullable long[] arr, String errorMessageTemplate, Object... args) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isEmpty(arr), errorMessageTemplate, args);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// isEmpty - double[]
|
|
|
|
|
public static <E extends Throwable> void isEmpty(@Nullable double[] arr, Supplier<E> e) throws E {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isEmpty(arr), e);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void isEmpty(@Nullable double[] arr, String errorMessage) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isEmpty(arr), errorMessage);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void isEmpty(@Nullable double[] arr, String errorMessageTemplate, Object... args) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isEmpty(arr), errorMessageTemplate, args);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-29 15:35:34 +08:00
|
|
|
// isNotEmpty - Array
|
2023-04-21 03:21:21 +08:00
|
|
|
public static <T, E extends Throwable> void isNotEmpty(@Nullable T[] arr, Supplier<E> e) throws E {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isNotEmpty(arr), e);
|
2023-04-21 03:21:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static <T> void isNotEmpty(@Nullable T[] arr, String errorMessage) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isNotEmpty(arr), errorMessage);
|
2023-04-21 03:21:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static <T> void isNotEmpty(@Nullable T[] arr, String errorMessageTemplate, Object... args) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isNotEmpty(arr), errorMessageTemplate, args);
|
2023-04-21 03:21:21 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-30 09:56:16 +08:00
|
|
|
// isNotEmpty - int[]
|
|
|
|
|
public static <E extends Throwable> void isNotEmpty(@Nullable int[] arr, Supplier<E> e) throws E {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isNotEmpty(arr), e);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void isNotEmpty(@Nullable int[] arr, String errorMessage) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isNotEmpty(arr), errorMessage);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void isNotEmpty(@Nullable int[] arr, String errorMessageTemplate, Object... args) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isNotEmpty(arr), errorMessageTemplate, args);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// isNotEmpty - long[]
|
|
|
|
|
public static <E extends Throwable> void isNotEmpty(@Nullable long[] arr, Supplier<E> e) throws E {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isNotEmpty(arr), e);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void isNotEmpty(@Nullable long[] arr, String errorMessage) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isNotEmpty(arr), errorMessage);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void isNotEmpty(@Nullable long[] arr, String errorMessageTemplate, Object... args) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isNotEmpty(arr), errorMessageTemplate, args);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// isNotEmpty - double[]
|
|
|
|
|
public static <E extends Throwable> void isNotEmpty(@Nullable double[] arr, Supplier<E> e) throws E {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isNotEmpty(arr), e);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void isNotEmpty(@Nullable double[] arr, String errorMessage) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isNotEmpty(arr), errorMessage);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void isNotEmpty(@Nullable double[] arr, String errorMessageTemplate, Object... args) {
|
2023-05-08 21:56:45 +08:00
|
|
|
Assert.isTrue(ArrayUtils.isNotEmpty(arr), errorMessageTemplate, args);
|
2023-04-30 09:56:16 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-29 15:35:34 +08:00
|
|
|
// isEmpty - String
|
|
|
|
|
public static <E extends Throwable> void isEmpty(@Nullable String str, Supplier<E> e) throws E {
|
2023-05-08 21:56:45 +08:00
|
|
|
if (!StringUtils.isEmpty(str)) {
|
|
|
|
|
throw e.get();
|
|
|
|
|
}
|
2023-04-21 03:21:21 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-29 15:35:34 +08:00
|
|
|
public static void isEmpty(@Nullable String str, String errorMessage) {
|
2023-05-08 21:56:45 +08:00
|
|
|
if (!StringUtils.isEmpty(str)) {
|
|
|
|
|
throw new IllegalArgumentException(errorMessage);
|
|
|
|
|
}
|
2023-04-21 03:21:21 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-29 15:35:34 +08:00
|
|
|
public static void isEmpty(@Nullable String str, String errorMessageTemplate, Object... args) {
|
2023-05-08 21:56:45 +08:00
|
|
|
if (!StringUtils.isEmpty(str)) {
|
|
|
|
|
throw new IllegalArgumentException(String.format(errorMessageTemplate, args));
|
|
|
|
|
}
|
2023-04-21 03:21:21 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-29 15:35:34 +08:00
|
|
|
// isNotEmpty - String
|
|
|
|
|
public static <E extends Throwable> void isNotEmpty(@Nullable String str, Supplier<E> e) throws E {
|
2023-05-08 21:56:45 +08:00
|
|
|
if (!StringUtils.isNotEmpty(str)) {
|
|
|
|
|
throw e.get();
|
|
|
|
|
}
|
2023-04-21 03:21:21 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-29 15:35:34 +08:00
|
|
|
public static void isNotEmpty(@Nullable String str, String errorMessage) {
|
2023-05-08 21:56:45 +08:00
|
|
|
if (!StringUtils.isNotEmpty(str)) {
|
|
|
|
|
throw new IllegalArgumentException(errorMessage);
|
|
|
|
|
}
|
2023-04-21 03:21:21 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-29 15:35:34 +08:00
|
|
|
public static void isNotEmpty(@Nullable String str, String errorMessageTemplate, Object... args) {
|
2023-05-08 21:56:45 +08:00
|
|
|
if (!StringUtils.isNotEmpty(str)) {
|
|
|
|
|
throw new IllegalArgumentException(String.format(errorMessageTemplate, args));
|
|
|
|
|
}
|
2023-04-21 03:21:21 +08:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 21:56:45 +08:00
|
|
|
// isNotBlank - String
|
|
|
|
|
public static <E extends Throwable> void isNotBlank(@Nullable String str, Supplier<E> e) throws E {
|
|
|
|
|
if (!StringUtils.isNotBlank(str)) {
|
2023-04-30 11:11:44 +08:00
|
|
|
throw e.get();
|
|
|
|
|
}
|
2023-04-29 17:45:20 +08:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 21:56:45 +08:00
|
|
|
public static void isNotBlank(@Nullable String str, String errorMessage) {
|
|
|
|
|
if (!StringUtils.isNotBlank(str)) {
|
2023-04-30 11:11:44 +08:00
|
|
|
throw new IllegalArgumentException(errorMessage);
|
|
|
|
|
}
|
2023-04-29 17:45:20 +08:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 21:56:45 +08:00
|
|
|
public static void isNotBlank(@Nullable String str, String errorMessageTemplate, Object... args) {
|
|
|
|
|
if (!StringUtils.isNotBlank(str)) {
|
2023-04-30 11:11:44 +08:00
|
|
|
throw new IllegalArgumentException(String.format(errorMessageTemplate, args));
|
|
|
|
|
}
|
2023-04-29 17:45:20 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-25 09:06:00 +08:00
|
|
|
// private constructor
|
2023-04-21 01:46:46 +08:00
|
|
|
private Assert() {
|
|
|
|
|
throw new IllegalStateException("Utility class");
|
|
|
|
|
}
|
|
|
|
|
}
|