会员 mainShopId
This commit is contained in:
@@ -20,11 +20,16 @@ public class AssertUtil {
|
||||
|
||||
/**
|
||||
* 判断两个对象是否不相等,如果不相等则抛出异常
|
||||
* @param a 实际值
|
||||
* @param b 期望值
|
||||
*
|
||||
* @param a 实际值
|
||||
* @param b 期望值
|
||||
* @param message 异常消息
|
||||
*/
|
||||
public static void isNotEqual(Object a, Object b, String message) {
|
||||
// 检查是否有任何一个为null
|
||||
if (a == null || b == null) {
|
||||
throw new ValidateException("参数不能为null: " + message);
|
||||
}
|
||||
// 如果实际值与期望值不相等,则抛出异常
|
||||
if (!Objects.equals(a, b)) {
|
||||
throw new ValidateException(message);
|
||||
@@ -43,6 +48,7 @@ public class AssertUtil {
|
||||
throw new ValidateException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查字符串是否不为空或空白字符,如果为空或空白字符则抛出异常
|
||||
*
|
||||
@@ -54,6 +60,7 @@ public class AssertUtil {
|
||||
public static void isBlank(String str, String errorMsgTemplate, Object... params) {
|
||||
isBlank(str, StrUtil.format(errorMsgTemplate, params));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查对象是否不为 null,如果为 null 则抛出异常
|
||||
*
|
||||
@@ -66,6 +73,7 @@ public class AssertUtil {
|
||||
throw new ValidateException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查对象是否不为 null,如果为 null 则抛出异常
|
||||
*
|
||||
@@ -77,6 +85,7 @@ public class AssertUtil {
|
||||
public static void isNull(Object object, String errorMsgTemplate, Object... params) {
|
||||
isNull(object, StrUtil.format(errorMsgTemplate, params));
|
||||
}
|
||||
|
||||
public static void isTrue(boolean flag, String errorMsgTemplate, Object... params) {
|
||||
if (flag) {
|
||||
throw new ValidateException(StrUtil.format(errorMsgTemplate, params));
|
||||
@@ -95,6 +104,7 @@ public class AssertUtil {
|
||||
throw new ValidateException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查数组是否不为空,如果为空则抛出异常
|
||||
*
|
||||
@@ -106,6 +116,7 @@ public class AssertUtil {
|
||||
public static void isArrayEmpty(Object[] array, String errorMsgTemplate, Object... params) {
|
||||
isArrayEmpty(array, StrUtil.format(errorMsgTemplate, params));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查列表是否不为空,如果为空则抛出异常
|
||||
*
|
||||
@@ -118,6 +129,7 @@ public class AssertUtil {
|
||||
throw new ValidateException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查列表是否不为空,如果为空则抛出异常
|
||||
*
|
||||
@@ -129,13 +141,14 @@ public class AssertUtil {
|
||||
public static void isListEmpty(List<?> list, String errorMsgTemplate, Object... params) {
|
||||
isListEmpty(list, StrUtil.format(errorMsgTemplate, params));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查 Map 是否不为空,如果为空则抛出异常
|
||||
*
|
||||
* @param <K> Map 的键类型
|
||||
* @param <V> Map 的值类型
|
||||
* @param map 要检查的 Map
|
||||
* @param msg 异常信息
|
||||
* @param <K> Map 的键类型
|
||||
* @param <V> Map 的值类型
|
||||
* @param map 要检查的 Map
|
||||
* @param msg 异常信息
|
||||
* @throws ValidateException 如果 Map 为空
|
||||
*/
|
||||
public static <K, V> void isMapEmpty(Map<K, V> map, String msg) {
|
||||
@@ -143,6 +156,7 @@ public class AssertUtil {
|
||||
throw new ValidateException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查 Map 是否不为空,如果为空则抛出异常
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user