mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-10 19:03:08 +08:00
refactor: 根据 Sonar 建议调整,StrUtil => CharSequenceUtil
工具层调整以减少 Sonar 建议,应用层则可忽略,怎么用方便怎么来
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
package top.charles7c.continew.starter.core.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import org.springframework.boot.env.YamlPropertySourceLoader;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -43,7 +43,7 @@ public class GeneralPropertySourceFactory extends DefaultPropertySourceFactory {
|
||||
EncodedResource encodedResource) throws IOException {
|
||||
Resource resource = encodedResource.getResource();
|
||||
String resourceName = resource.getFilename();
|
||||
if (StrUtil.isNotBlank(resourceName) && StrUtil.endWithAny(resourceName, ".yml", ".yaml")) {
|
||||
if (CharSequenceUtil.isNotBlank(resourceName) && CharSequenceUtil.endWithAny(resourceName, ".yml", ".yaml")) {
|
||||
return new YamlPropertySourceLoader().load(resourceName, resource).get(0);
|
||||
}
|
||||
return super.createPropertySource(name, encodedResource);
|
||||
|
@@ -18,7 +18,7 @@ package top.charles7c.continew.starter.core.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.net.NetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.http.HtmlUtil;
|
||||
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
|
||||
@@ -52,7 +52,7 @@ public class IpUtils {
|
||||
IpInfo ipInfo = ip2regionSearcher.memorySearch(ip);
|
||||
if (null != ipInfo) {
|
||||
Set<String> regionSet = CollUtil.newLinkedHashSet(ipInfo.getAddress(), ipInfo.getIsp());
|
||||
regionSet.removeIf(StrUtil::isBlank);
|
||||
regionSet.removeIf(CharSequenceUtil::isBlank);
|
||||
return String.join(StringConstants.SPACE, regionSet);
|
||||
}
|
||||
return null;
|
||||
|
@@ -17,7 +17,7 @@
|
||||
package top.charles7c.continew.starter.core.util.db;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.db.Db;
|
||||
import cn.hutool.db.Entity;
|
||||
import cn.hutool.db.meta.Column;
|
||||
@@ -61,7 +61,7 @@ public class MetaUtils {
|
||||
String querySql = "SHOW TABLE STATUS";
|
||||
List<Entity> tableEntityList;
|
||||
Db db = Db.use(dataSource);
|
||||
if (StrUtil.isNotBlank(tableName)) {
|
||||
if (CharSequenceUtil.isNotBlank(tableName)) {
|
||||
tableEntityList = db.query(String.format("%s WHERE NAME = ?", querySql), tableName);
|
||||
} else {
|
||||
tableEntityList = db.query(querySql);
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package top.charles7c.continew.starter.core.util.validate;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||
import top.charles7c.continew.starter.core.exception.BusinessException;
|
||||
|
||||
@@ -45,7 +45,7 @@ public class CheckUtils extends Validator {
|
||||
* @param fieldValue 字段值
|
||||
*/
|
||||
public static void throwIfNotExists(Object obj, String entityName, String fieldName, Object fieldValue) {
|
||||
String message = String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue, StrUtil
|
||||
String message = String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue, CharSequenceUtil
|
||||
.replace(entityName, "DO", StringConstants.EMPTY));
|
||||
throwIfNull(obj, message, EXCEPTION_TYPE);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class CheckUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfNull(Object obj, String template, Object... params) {
|
||||
throwIfNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfNull(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,7 +69,7 @@ public class CheckUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfNotNull(Object obj, String template, Object... params) {
|
||||
throwIfNotNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfNotNull(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +93,7 @@ public class CheckUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfEmpty(Object obj, String template, Object... params) {
|
||||
throwIfEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfEmpty(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ public class CheckUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfNotEmpty(Object obj, String template, Object... params) {
|
||||
throwIfNotEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfNotEmpty(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ public class CheckUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfBlank(CharSequence str, String template, Object... params) {
|
||||
throwIfBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfBlank(str, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +126,7 @@ public class CheckUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfNotBlank(CharSequence str, String template, Object... params) {
|
||||
throwIfNotBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfNotBlank(str, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,7 +138,7 @@ public class CheckUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfEqual(Object obj1, Object obj2, String template, Object... params) {
|
||||
throwIfEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfEqual(obj1, obj2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,7 +150,7 @@ public class CheckUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfNotEqual(Object obj1, Object obj2, String template, Object... params) {
|
||||
throwIfNotEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfNotEqual(obj1, obj2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,7 +162,7 @@ public class CheckUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, Object... params) {
|
||||
throwIfEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfEqualIgnoreCase(str1, str2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,7 +177,7 @@ public class CheckUtils extends Validator {
|
||||
CharSequence str2,
|
||||
String template,
|
||||
Object... params) {
|
||||
throwIfNotEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfNotEqualIgnoreCase(str1, str2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +188,7 @@ public class CheckUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIf(boolean condition, String template, Object... params) {
|
||||
throwIf(condition, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIf(condition, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,6 +199,6 @@ public class CheckUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIf(BooleanSupplier conditionSupplier, String template, Object... params) {
|
||||
throwIf(conditionSupplier, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIf(conditionSupplier, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package top.charles7c.continew.starter.core.util.validate;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import top.charles7c.continew.starter.core.exception.BadRequestException;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
@@ -43,7 +43,7 @@ public class ValidationUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfNull(Object obj, String template, Object... params) {
|
||||
throwIfNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfNull(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ public class ValidationUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfNotNull(Object obj, String template, Object... params) {
|
||||
throwIfNotNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfNotNull(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ public class ValidationUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfEmpty(Object obj, String template, Object... params) {
|
||||
throwIfEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfEmpty(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +76,7 @@ public class ValidationUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfNotEmpty(Object obj, String template, Object... params) {
|
||||
throwIfNotEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfNotEmpty(obj, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ public class ValidationUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfBlank(CharSequence str, String template, Object... params) {
|
||||
throwIfBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfBlank(str, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ public class ValidationUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfNotBlank(CharSequence str, String template, Object... params) {
|
||||
throwIfNotBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfNotBlank(str, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,7 @@ public class ValidationUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfEqual(Object obj1, Object obj2, String template, Object... params) {
|
||||
throwIfEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfEqual(obj1, obj2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +122,7 @@ public class ValidationUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfNotEqual(Object obj1, Object obj2, String template, Object... params) {
|
||||
throwIfNotEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfNotEqual(obj1, obj2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +134,7 @@ public class ValidationUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, Object... params) {
|
||||
throwIfEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfEqualIgnoreCase(str1, str2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +149,7 @@ public class ValidationUtils extends Validator {
|
||||
CharSequence str2,
|
||||
String template,
|
||||
Object... params) {
|
||||
throwIfNotEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIfNotEqualIgnoreCase(str1, str2, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,7 +160,7 @@ public class ValidationUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIf(boolean condition, String template, Object... params) {
|
||||
throwIf(condition, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIf(condition, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,6 +171,6 @@ public class ValidationUtils extends Validator {
|
||||
* @param params 参数值
|
||||
*/
|
||||
public static void throwIf(BooleanSupplier conditionSupplier, String template, Object... params) {
|
||||
throwIf(conditionSupplier, StrUtil.format(template, params), EXCEPTION_TYPE);
|
||||
throwIf(conditionSupplier, CharSequenceUtil.format(template, params), EXCEPTION_TYPE);
|
||||
}
|
||||
}
|
||||
|
@@ -16,9 +16,9 @@
|
||||
|
||||
package top.charles7c.continew.starter.core.util.validate;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -90,7 +90,7 @@ public class Validator {
|
||||
protected static void throwIfBlank(CharSequence str,
|
||||
String message,
|
||||
Class<? extends RuntimeException> exceptionType) {
|
||||
throwIf(StrUtil.isBlank(str), message, exceptionType);
|
||||
throwIf(CharSequenceUtil.isBlank(str), message, exceptionType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +103,7 @@ public class Validator {
|
||||
protected static void throwIfNotBlank(CharSequence str,
|
||||
String message,
|
||||
Class<? extends RuntimeException> exceptionType) {
|
||||
throwIf(StrUtil.isNotBlank(str), message, exceptionType);
|
||||
throwIf(CharSequenceUtil.isNotBlank(str), message, exceptionType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,7 +148,7 @@ public class Validator {
|
||||
CharSequence str2,
|
||||
String message,
|
||||
Class<? extends RuntimeException> exceptionType) {
|
||||
throwIf(StrUtil.equalsIgnoreCase(str1, str2), message, exceptionType);
|
||||
throwIf(CharSequenceUtil.equalsIgnoreCase(str1, str2), message, exceptionType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,7 +163,7 @@ public class Validator {
|
||||
CharSequence str2,
|
||||
String message,
|
||||
Class<? extends RuntimeException> exceptionType) {
|
||||
throwIf(!StrUtil.equalsIgnoreCase(str1, str2), message, exceptionType);
|
||||
throwIf(!CharSequenceUtil.equalsIgnoreCase(str1, str2), message, exceptionType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user