优化:优化校验器相关方法名

This commit is contained in:
2023-01-21 12:09:49 +08:00
parent c282a36b08
commit 185b79320f
11 changed files with 81 additions and 80 deletions

View File

@@ -186,7 +186,7 @@ public class MailUtils {
*/
public static void send(Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject,
String content, boolean isHtml, File... files) throws MessagingException {
CheckUtils.exIfCondition(() -> CollUtil.isEmpty(tos), "请至少指定一名收件人");
CheckUtils.throwIf(() -> CollUtil.isEmpty(tos), "请至少指定一名收件人");
MimeMessage mimeMessage = MAIL_SENDER.createMimeMessage();
MimeMessageHelper messageHelper =
new MimeMessageHelper(mimeMessage, true, StandardCharsets.UTF_8.displayName());

View File

@@ -57,7 +57,7 @@ public class SecureUtils {
*/
public static String decryptByRsaPrivateKey(String data) {
String privateKey = RsaProperties.PRIVATE_KEY;
ValidationUtils.exIfBlank(privateKey, "请配置 RSA 私钥");
ValidationUtils.throwIfBlank(privateKey, "请配置 RSA 私钥");
return decryptByRsaPrivateKey(data, privateKey);
}

View File

@@ -43,8 +43,8 @@ public class CheckUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfBlank(CharSequence str, String message) {
exIfBlank(str, message, EXCEPTION_TYPE);
public static void throwIfBlank(CharSequence str, String message) {
throwIfBlank(str, message, EXCEPTION_TYPE);
}
/**
@@ -55,8 +55,8 @@ public class CheckUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfNotBlank(CharSequence str, String message) {
exIfNotBlank(str, message, EXCEPTION_TYPE);
public static void throwIfNotBlank(CharSequence str, String message) {
throwIfNotBlank(str, message, EXCEPTION_TYPE);
}
/**
@@ -69,8 +69,8 @@ public class CheckUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfEqual(Object obj1, Object obj2, String message) {
exIfEqual(obj1, obj2, message, EXCEPTION_TYPE);
public static void throwIfEqual(Object obj1, Object obj2, String message) {
throwIfEqual(obj1, obj2, message, EXCEPTION_TYPE);
}
/**
@@ -83,8 +83,8 @@ public class CheckUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfNotEqual(Object obj1, Object obj2, String message) {
exIfNotEqual(obj1, obj2, message, EXCEPTION_TYPE);
public static void throwIfNotEqual(Object obj1, Object obj2, String message) {
throwIfNotEqual(obj1, obj2, message, EXCEPTION_TYPE);
}
/**
@@ -97,8 +97,8 @@ public class CheckUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String message) {
exIfEqualIgnoreCase(str1, str2, message, EXCEPTION_TYPE);
public static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String message) {
throwIfEqualIgnoreCase(str1, str2, message, EXCEPTION_TYPE);
}
/**
@@ -111,8 +111,8 @@ public class CheckUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String message) {
exIfNotEqualIgnoreCase(str1, str2, message, EXCEPTION_TYPE);
public static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String message) {
throwIfNotEqualIgnoreCase(str1, str2, message, EXCEPTION_TYPE);
}
/**
@@ -123,8 +123,8 @@ public class CheckUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfNull(Object obj, String message) {
exIfNull(obj, message, EXCEPTION_TYPE);
public static void throwIfNull(Object obj, String message) {
throwIfNull(obj, message, EXCEPTION_TYPE);
}
/**
@@ -135,8 +135,8 @@ public class CheckUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfNotNull(Object obj, String message) {
exIfNotNull(obj, message, EXCEPTION_TYPE);
public static void throwIfNotNull(Object obj, String message) {
throwIfNotNull(obj, message, EXCEPTION_TYPE);
}
/**
@@ -147,7 +147,7 @@ public class CheckUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfCondition(java.util.function.BooleanSupplier conditionSupplier, String message) {
exIfCondition(conditionSupplier, message, EXCEPTION_TYPE);
public static void throwIf(java.util.function.BooleanSupplier conditionSupplier, String message) {
throwIf(conditionSupplier, message, EXCEPTION_TYPE);
}
}

View File

@@ -43,8 +43,8 @@ public class ValidationUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfBlank(CharSequence str, String message) {
exIfBlank(str, message, EXCEPTION_TYPE);
public static void throwIfBlank(CharSequence str, String message) {
throwIfBlank(str, message, EXCEPTION_TYPE);
}
/**
@@ -55,8 +55,8 @@ public class ValidationUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfNotBlank(CharSequence str, String message) {
exIfNotBlank(str, message, EXCEPTION_TYPE);
public static void throwIfNotBlank(CharSequence str, String message) {
throwIfNotBlank(str, message, EXCEPTION_TYPE);
}
/**
@@ -69,8 +69,8 @@ public class ValidationUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfEqual(Object obj1, Object obj2, String message) {
exIfEqual(obj1, obj2, message, EXCEPTION_TYPE);
public static void throwIfEqual(Object obj1, Object obj2, String message) {
throwIfEqual(obj1, obj2, message, EXCEPTION_TYPE);
}
/**
@@ -83,8 +83,8 @@ public class ValidationUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfNotEqual(Object obj1, Object obj2, String message) {
exIfNotEqual(obj1, obj2, message, EXCEPTION_TYPE);
public static void throwIfNotEqual(Object obj1, Object obj2, String message) {
throwIfNotEqual(obj1, obj2, message, EXCEPTION_TYPE);
}
/**
@@ -97,8 +97,8 @@ public class ValidationUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String message) {
exIfEqualIgnoreCase(str1, str2, message, EXCEPTION_TYPE);
public static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String message) {
throwIfEqualIgnoreCase(str1, str2, message, EXCEPTION_TYPE);
}
/**
@@ -111,8 +111,8 @@ public class ValidationUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String message) {
exIfNotEqualIgnoreCase(str1, str2, message, EXCEPTION_TYPE);
public static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String message) {
throwIfNotEqualIgnoreCase(str1, str2, message, EXCEPTION_TYPE);
}
/**
@@ -123,8 +123,8 @@ public class ValidationUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfNull(Object obj, String message) {
exIfNull(obj, message, EXCEPTION_TYPE);
public static void throwIfNull(Object obj, String message) {
throwIfNull(obj, message, EXCEPTION_TYPE);
}
/**
@@ -135,8 +135,8 @@ public class ValidationUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfNotNull(Object obj, String message) {
exIfNotNull(obj, message, EXCEPTION_TYPE);
public static void throwIfNotNull(Object obj, String message) {
throwIfNotNull(obj, message, EXCEPTION_TYPE);
}
/**
@@ -147,7 +147,7 @@ public class ValidationUtils extends Validator {
* @param message
* 错误信息
*/
public static void exIfCondition(java.util.function.BooleanSupplier conditionSupplier, String message) {
exIfCondition(conditionSupplier, message, EXCEPTION_TYPE);
public static void throwIf(java.util.function.BooleanSupplier conditionSupplier, String message) {
throwIf(conditionSupplier, message, EXCEPTION_TYPE);
}
}

View File

@@ -44,8 +44,9 @@ public class Validator {
* @param exceptionType
* 异常类型
*/
protected static void exIfBlank(CharSequence str, String message, Class<? extends RuntimeException> exceptionType) {
exIfCondition(() -> StrUtil.isBlank(str), message, exceptionType);
protected static void throwIfBlank(CharSequence str, String message,
Class<? extends RuntimeException> exceptionType) {
throwIf(() -> StrUtil.isBlank(str), message, exceptionType);
}
/**
@@ -58,9 +59,9 @@ public class Validator {
* @param exceptionType
* 异常类型
*/
protected static void exIfNotBlank(CharSequence str, String message,
protected static void throwIfNotBlank(CharSequence str, String message,
Class<? extends RuntimeException> exceptionType) {
exIfCondition(() -> StrUtil.isNotBlank(str), message, exceptionType);
throwIf(() -> StrUtil.isNotBlank(str), message, exceptionType);
}
/**
@@ -75,9 +76,9 @@ public class Validator {
* @param exceptionType
* 异常类型
*/
protected static void exIfEqual(Object obj1, Object obj2, String message,
protected static void throwIfEqual(Object obj1, Object obj2, String message,
Class<? extends RuntimeException> exceptionType) {
exIfCondition(() -> ObjectUtil.equal(obj1, obj2), message, exceptionType);
throwIf(() -> ObjectUtil.equal(obj1, obj2), message, exceptionType);
}
/**
@@ -92,9 +93,9 @@ public class Validator {
* @param exceptionType
* 异常类型
*/
protected static void exIfNotEqual(Object obj1, Object obj2, String message,
protected static void throwIfNotEqual(Object obj1, Object obj2, String message,
Class<? extends RuntimeException> exceptionType) {
exIfCondition(() -> ObjectUtil.notEqual(obj1, obj2), message, exceptionType);
throwIf(() -> ObjectUtil.notEqual(obj1, obj2), message, exceptionType);
}
/**
@@ -109,9 +110,9 @@ public class Validator {
* @param exceptionType
* 异常类型
*/
protected static void exIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String message,
protected static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String message,
Class<? extends RuntimeException> exceptionType) {
exIfCondition(() -> StrUtil.equalsIgnoreCase(str1, str2), message, exceptionType);
throwIf(() -> StrUtil.equalsIgnoreCase(str1, str2), message, exceptionType);
}
/**
@@ -126,9 +127,9 @@ public class Validator {
* @param exceptionType
* 异常类型
*/
protected static void exIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String message,
protected static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String message,
Class<? extends RuntimeException> exceptionType) {
exIfCondition(() -> !StrUtil.equalsIgnoreCase(str1, str2), message, exceptionType);
throwIf(() -> !StrUtil.equalsIgnoreCase(str1, str2), message, exceptionType);
}
/**
@@ -141,8 +142,8 @@ public class Validator {
* @param exceptionType
* 异常类型
*/
protected static void exIfNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
exIfCondition(() -> obj == null, message, exceptionType);
protected static void throwIfNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
throwIf(() -> obj == null, message, exceptionType);
}
/**
@@ -155,8 +156,8 @@ public class Validator {
* @param exceptionType
* 异常类型
*/
protected static void exIfNotNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
exIfCondition(() -> obj != null, message, exceptionType);
protected static void throwIfNotNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
throwIf(() -> obj != null, message, exceptionType);
}
/**
@@ -169,7 +170,7 @@ public class Validator {
* @param exceptionType
* 异常类型
*/
protected static void exIfCondition(java.util.function.BooleanSupplier conditionSupplier, String message,
protected static void throwIf(java.util.function.BooleanSupplier conditionSupplier, String message,
Class<? extends RuntimeException> exceptionType) {
if (conditionSupplier != null && conditionSupplier.getAsBoolean()) {
log.error(message);