From ae7a267c1d5b4b0fafc54e08e915383b49e47b01 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Sat, 17 May 2025 13:50:59 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC=20null=20!=3D=20xx=20=3D>=20xx=20!=3D=20null?= =?UTF-8?q?=EF=BC=88=E6=9B=B4=E7=AC=A6=E5=90=88=E5=A4=A7=E4=BC=97=E9=A3=8E?= =?UTF-8?q?=E6=A0=BC=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SpringDocAutoConfiguration.java | 10 ++++----- .../RedissonAutoConfiguration.java | 6 ++--- .../SpringCacheAutoConfiguration.java | 2 +- .../core/constant/StringConstants.java | 2 +- .../starter/core/util/ExceptionUtils.java | 4 ++-- .../starter/core/validation/Validator.java | 4 ++-- .../starter/data/core/util/MetaUtils.java | 2 +- .../data/mf/util/QueryWrapperHelper.java | 2 +- .../MybatisPlusAutoConfiguration.java | 2 +- .../data/mp/util/QueryWrapperHelper.java | 2 +- .../CrudRequestMappingHandlerMapping.java | 6 ++--- .../handler/DefaultDataPermissionHandler.java | 10 ++++----- .../line/DefaultTenantLineHandler.java | 4 ++-- .../converter/ExcelBigNumberConverter.java | 2 +- .../SimpleDeserializersWrapper.java | 4 ++-- .../log/handler/AbstractLogHandler.java | 22 +++++++++---------- .../core/AbstractMyBatisInterceptor.java | 4 ++-- .../core/MyBatisEncryptInterceptor.java | 6 ++--- .../starter/web/util/SpringWebUtils.java | 3 ++- 19 files changed, 49 insertions(+), 48 deletions(-) diff --git a/continew-starter-api-doc/src/main/java/top/continew/starter/apidoc/autoconfigure/SpringDocAutoConfiguration.java b/continew-starter-api-doc/src/main/java/top/continew/starter/apidoc/autoconfigure/SpringDocAutoConfiguration.java index c81aaca1..62417e08 100644 --- a/continew-starter-api-doc/src/main/java/top/continew/starter/apidoc/autoconfigure/SpringDocAutoConfiguration.java +++ b/continew-starter-api-doc/src/main/java/top/continew/starter/apidoc/autoconfigure/SpringDocAutoConfiguration.java @@ -87,17 +87,17 @@ public class SpringDocAutoConfiguration implements WebMvcConfigurer { .version(projectProperties.getVersion()) .description(projectProperties.getDescription()); ProjectProperties.Contact contact = projectProperties.getContact(); - if (null != contact) { + if (contact != null) { info.contact(new Contact().name(contact.getName()).email(contact.getEmail()).url(contact.getUrl())); } ProjectProperties.License license = projectProperties.getLicense(); - if (null != license) { + if (license != null) { info.license(new License().name(license.getName()).url(license.getUrl())); } OpenAPI openApi = new OpenAPI(); openApi.info(info); Components components = properties.getComponents(); - if (null != components) { + if (components != null) { openApi.components(components); // 鉴权配置 Map securitySchemeMap = components.getSecuritySchemes(); @@ -118,11 +118,11 @@ public class SpringDocAutoConfiguration implements WebMvcConfigurer { @ConditionalOnMissingBean public GlobalOpenApiCustomizer globalOpenApiCustomizer(SpringDocExtensionProperties properties) { return openApi -> { - if (null != openApi.getPaths()) { + if (openApi.getPaths() != null) { openApi.getPaths().forEach((s, pathItem) -> { // 为所有接口添加鉴权 Components components = properties.getComponents(); - if (null != components && MapUtil.isNotEmpty(components.getSecuritySchemes())) { + if (components != null && MapUtil.isNotEmpty(components.getSecuritySchemes())) { Map securitySchemeMap = components.getSecuritySchemes(); pathItem.readOperations().forEach(operation -> { SecurityRequirement securityRequirement = new SecurityRequirement(); diff --git a/continew-starter-cache/continew-starter-cache-redisson/src/main/java/top/continew/starter/cache/redisson/autoconfigure/RedissonAutoConfiguration.java b/continew-starter-cache/continew-starter-cache-redisson/src/main/java/top/continew/starter/cache/redisson/autoconfigure/RedissonAutoConfiguration.java index 5c461783..c08ebace 100644 --- a/continew-starter-cache/continew-starter-cache-redisson/src/main/java/top/continew/starter/cache/redisson/autoconfigure/RedissonAutoConfiguration.java +++ b/continew-starter-cache/continew-starter-cache-redisson/src/main/java/top/continew/starter/cache/redisson/autoconfigure/RedissonAutoConfiguration.java @@ -93,7 +93,7 @@ public class RedissonAutoConfiguration { private void buildClusterModeConfig(Config config, String protocolPrefix) { ClusterServersConfig clusterServersConfig = config.useClusterServers(); ClusterServersConfig customClusterServersConfig = properties.getClusterServersConfig(); - if (null != customClusterServersConfig) { + if (customClusterServersConfig != null) { BeanUtil.copyProperties(customClusterServersConfig, clusterServersConfig); clusterServersConfig.setNodeAddresses(customClusterServersConfig.getNodeAddresses()); } @@ -122,7 +122,7 @@ public class RedissonAutoConfiguration { private void buildSentinelModeConfig(Config config, String protocolPrefix) { SentinelServersConfig sentinelServersConfig = config.useSentinelServers(); SentinelServersConfig customSentinelServersConfig = properties.getSentinelServersConfig(); - if (null != customSentinelServersConfig) { + if (customSentinelServersConfig != null) { BeanUtil.copyProperties(customSentinelServersConfig, sentinelServersConfig); sentinelServersConfig.setSentinelAddresses(customSentinelServersConfig.getSentinelAddresses()); } @@ -154,7 +154,7 @@ public class RedissonAutoConfiguration { private void buildSingleModeConfig(Config config, String protocolPrefix) { SingleServerConfig singleServerConfig = config.useSingleServer(); SingleServerConfig customSingleServerConfig = properties.getSingleServerConfig(); - if (null != customSingleServerConfig) { + if (customSingleServerConfig != null) { BeanUtil.copyProperties(properties.getSingleServerConfig(), singleServerConfig); } // 下方配置如果为空,则使用 Redis 的配置 diff --git a/continew-starter-cache/continew-starter-cache-springcache/src/main/java/top/continew/starter/cache/springcache/autoconfigure/SpringCacheAutoConfiguration.java b/continew-starter-cache/continew-starter-cache-springcache/src/main/java/top/continew/starter/cache/springcache/autoconfigure/SpringCacheAutoConfiguration.java index 0b324eca..8d934c8f 100644 --- a/continew-starter-cache/continew-starter-cache-springcache/src/main/java/top/continew/starter/cache/springcache/autoconfigure/SpringCacheAutoConfiguration.java +++ b/continew-starter-cache/continew-starter-cache-springcache/src/main/java/top/continew/starter/cache/springcache/autoconfigure/SpringCacheAutoConfiguration.java @@ -72,7 +72,7 @@ public class SpringCacheAutoConfiguration implements CachingConfigurer { .serializeValuesWith(RedisSerializationContext.SerializationPair .fromSerializer(new GenericJackson2JsonRedisSerializer(objectMapperCopy))); CacheProperties.Redis redisCacheProperties = cacheProperties.getRedis(); - if (null != redisCacheProperties.getTimeToLive()) { + if (redisCacheProperties.getTimeToLive() != null) { redisCacheConfiguration = redisCacheConfiguration.entryTtl(redisCacheProperties.getTimeToLive()); } if (!redisCacheProperties.isCacheNullValues()) { diff --git a/continew-starter-core/src/main/java/top/continew/starter/core/constant/StringConstants.java b/continew-starter-core/src/main/java/top/continew/starter/core/constant/StringConstants.java index df86ded5..7d200d7f 100644 --- a/continew-starter-core/src/main/java/top/continew/starter/core/constant/StringConstants.java +++ b/continew-starter-core/src/main/java/top/continew/starter/core/constant/StringConstants.java @@ -115,7 +115,7 @@ public class StringConstants { public static final String SLASH = "/"; /** - * 双斜杠 {@code "//"} + * 双斜杠 {@code "//"} */ public static final String DOUBLE_SLASH = "//"; diff --git a/continew-starter-core/src/main/java/top/continew/starter/core/util/ExceptionUtils.java b/continew-starter-core/src/main/java/top/continew/starter/core/util/ExceptionUtils.java index 0414baaa..fc7783dd 100644 --- a/continew-starter-core/src/main/java/top/continew/starter/core/util/ExceptionUtils.java +++ b/continew-starter-core/src/main/java/top/continew/starter/core/util/ExceptionUtils.java @@ -57,7 +57,7 @@ public class ExceptionUtils { Thread.currentThread().interrupt(); } } - if (null != throwable) { + if (throwable != null) { log.error(throwable.getMessage(), throwable); } } @@ -120,7 +120,7 @@ public class ExceptionUtils { try { return exSupplier.get(); } catch (Exception e) { - if (null != exConsumer) { + if (exConsumer != null) { exConsumer.accept(e); } return defaultValue; diff --git a/continew-starter-core/src/main/java/top/continew/starter/core/validation/Validator.java b/continew-starter-core/src/main/java/top/continew/starter/core/validation/Validator.java index 061facd7..4f16da15 100644 --- a/continew-starter-core/src/main/java/top/continew/starter/core/validation/Validator.java +++ b/continew-starter-core/src/main/java/top/continew/starter/core/validation/Validator.java @@ -59,7 +59,7 @@ public class Validator { * @param exceptionType 异常类型 */ protected static void throwIfNotNull(Object obj, String message, Class exceptionType) { - throwIf(null != obj, message, exceptionType); + throwIf(obj != null, message, exceptionType); } /** @@ -193,7 +193,7 @@ public class Validator { protected static void throwIf(BooleanSupplier conditionSupplier, String message, Class exceptionType) { - if (null != conditionSupplier && conditionSupplier.getAsBoolean()) { + if (conditionSupplier != null && conditionSupplier.getAsBoolean()) { throw ReflectUtil.newInstance(exceptionType, message); } } diff --git a/continew-starter-data/continew-starter-data-core/src/main/java/top/continew/starter/data/core/util/MetaUtils.java b/continew-starter-data/continew-starter-data-core/src/main/java/top/continew/starter/data/core/util/MetaUtils.java index d895ee40..e752df00 100644 --- a/continew-starter-data/continew-starter-data-core/src/main/java/top/continew/starter/data/core/util/MetaUtils.java +++ b/continew-starter-data/continew-starter-data-core/src/main/java/top/continew/starter/data/core/util/MetaUtils.java @@ -106,7 +106,7 @@ public class MetaUtils { final DatabaseMetaData metaData = conn.getMetaData(); try (final ResultSet rs = metaData.getTables(catalog, schema, tableName, Convert .toStrArray(TableType.TABLE))) { - if (null != rs) { + if (rs != null) { String name; while (rs.next()) { name = rs.getString("TABLE_NAME"); diff --git a/continew-starter-data/continew-starter-data-mf/src/main/java/top/continew/starter/data/mf/util/QueryWrapperHelper.java b/continew-starter-data/continew-starter-data-mf/src/main/java/top/continew/starter/data/mf/util/QueryWrapperHelper.java index 059dd443..21f2dc72 100644 --- a/continew-starter-data/continew-starter-data-mf/src/main/java/top/continew/starter/data/mf/util/QueryWrapperHelper.java +++ b/continew-starter-data/continew-starter-data-mf/src/main/java/top/continew/starter/data/mf/util/QueryWrapperHelper.java @@ -143,7 +143,7 @@ public class QueryWrapperHelper { } // 设置了 @QueryIgnore 注解,直接忽略 QueryIgnore queryIgnoreAnnotation = AnnotationUtil.getAnnotation(field, QueryIgnore.class); - if (null != queryIgnoreAnnotation) { + if (queryIgnoreAnnotation != null) { return Collections.emptyList(); } // 建议:数据库表列建议采用下划线连接法命名,程序变量建议采用驼峰法命名 diff --git a/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/autoconfigure/MybatisPlusAutoConfiguration.java b/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/autoconfigure/MybatisPlusAutoConfiguration.java index 59aa3764..d3a3eed4 100644 --- a/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/autoconfigure/MybatisPlusAutoConfiguration.java +++ b/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/autoconfigure/MybatisPlusAutoConfiguration.java @@ -84,7 +84,7 @@ public class MybatisPlusAutoConfiguration { } // 分页插件 MyBatisPlusExtensionProperties.PaginationProperties paginationProperties = properties.getPagination(); - if (null != paginationProperties && paginationProperties.isEnabled()) { + if (paginationProperties != null && paginationProperties.isEnabled()) { interceptor.addInnerInterceptor(this.paginationInnerInterceptor(paginationProperties)); } // 乐观锁插件 diff --git a/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/util/QueryWrapperHelper.java b/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/util/QueryWrapperHelper.java index 1557fccf..f2b40146 100644 --- a/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/util/QueryWrapperHelper.java +++ b/continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/util/QueryWrapperHelper.java @@ -154,7 +154,7 @@ public class QueryWrapperHelper { } // 设置了 @QueryIgnore 注解,直接忽略 QueryIgnore queryIgnoreAnnotation = AnnotationUtil.getAnnotation(field, QueryIgnore.class); - if (null != queryIgnoreAnnotation) { + if (queryIgnoreAnnotation != null) { return Collections.emptyList(); } // 建议:数据库表列建议采用下划线连接法命名,程序变量建议采用驼峰法命名 diff --git a/continew-starter-extension/continew-starter-extension-crud/continew-starter-extension-crud-core/src/main/java/top/continew/starter/extension/crud/autoconfigure/CrudRequestMappingHandlerMapping.java b/continew-starter-extension/continew-starter-extension-crud/continew-starter-extension-crud-core/src/main/java/top/continew/starter/extension/crud/autoconfigure/CrudRequestMappingHandlerMapping.java index 8852d52e..b726699d 100644 --- a/continew-starter-extension/continew-starter-extension-crud/continew-starter-extension-crud-core/src/main/java/top/continew/starter/extension/crud/autoconfigure/CrudRequestMappingHandlerMapping.java +++ b/continew-starter-extension/continew-starter-extension-crud/continew-starter-extension-crud-core/src/main/java/top/continew/starter/extension/crud/autoconfigure/CrudRequestMappingHandlerMapping.java @@ -64,13 +64,13 @@ public class CrudRequestMappingHandlerMapping extends RequestMappingHandlerMappi @NonNull Class handlerType, CrudRequestMapping crudRequestMapping) { RequestMappingInfo info = this.buildRequestMappingInfo(method); - if (null != info) { + if (info != null) { RequestMappingInfo typeInfo = this.buildRequestMappingInfo(handlerType); - if (null != typeInfo) { + if (typeInfo != null) { info = typeInfo.combine(info); } String prefix = crudRequestMapping.value(); - if (null != prefix) { + if (prefix != null) { RequestMappingInfo.BuilderConfiguration options = new RequestMappingInfo.BuilderConfiguration(); options.setPatternParser(PathPatternParser.defaultInstance); info = RequestMappingInfo.paths(prefix).options(options).build().combine(info); diff --git a/continew-starter-extension/continew-starter-extension-datapermission/continew-starter-extension-datapermission-mp/src/main/java/top/continew/starter/extension/datapermission/handler/DefaultDataPermissionHandler.java b/continew-starter-extension/continew-starter-extension-datapermission/continew-starter-extension-datapermission-mp/src/main/java/top/continew/starter/extension/datapermission/handler/DefaultDataPermissionHandler.java index 0e309ea6..226ee9ff 100644 --- a/continew-starter-extension/continew-starter-extension-datapermission/continew-starter-extension-datapermission-mp/src/main/java/top/continew/starter/extension/datapermission/handler/DefaultDataPermissionHandler.java +++ b/continew-starter-extension/continew-starter-extension-datapermission/continew-starter-extension-datapermission-mp/src/main/java/top/continew/starter/extension/datapermission/handler/DefaultDataPermissionHandler.java @@ -120,7 +120,7 @@ public class DefaultDataPermissionHandler implements DataPermissionHandler { default -> throw new IllegalArgumentException("暂不支持 [%s] 数据权限".formatted(dataScope)); } } - return null != where ? new AndExpression(where, new ParenthesedExpressionList<>(expression)) : expression; + return where != null ? new AndExpression(where, new ParenthesedExpressionList<>(expression)) : expression; } /** @@ -176,7 +176,7 @@ public class DefaultDataPermissionHandler implements DataPermissionHandler { InExpression inExpression = new InExpression(); inExpression.setLeftExpression(this.buildColumn(dataPermission.tableAlias(), dataPermission.deptId())); inExpression.setRightExpression(subSelect); - return null != expression ? new OrExpression(expression, inExpression) : inExpression; + return expression != null ? new OrExpression(expression, inExpression) : inExpression; } /** @@ -197,7 +197,7 @@ public class DefaultDataPermissionHandler implements DataPermissionHandler { EqualsTo equalsTo = new EqualsTo(); equalsTo.setLeftExpression(this.buildColumn(dataPermission.tableAlias(), dataPermission.deptId())); equalsTo.setRightExpression(new LongValue(userContext.getDeptId())); - return null != expression ? new OrExpression(expression, equalsTo) : equalsTo; + return expression != null ? new OrExpression(expression, equalsTo) : equalsTo; } /** @@ -218,7 +218,7 @@ public class DefaultDataPermissionHandler implements DataPermissionHandler { EqualsTo equalsTo = new EqualsTo(); equalsTo.setLeftExpression(this.buildColumn(dataPermission.tableAlias(), dataPermission.userId())); equalsTo.setRightExpression(new LongValue(userContext.getUserId())); - return null != expression ? new OrExpression(expression, equalsTo) : equalsTo; + return expression != null ? new OrExpression(expression, equalsTo) : equalsTo; } /** @@ -250,7 +250,7 @@ public class DefaultDataPermissionHandler implements DataPermissionHandler { InExpression inExpression = new InExpression(); inExpression.setLeftExpression(this.buildColumn(dataPermission.tableAlias(), dataPermission.deptId())); inExpression.setRightExpression(subSelect); - return null != expression ? new OrExpression(expression, inExpression) : inExpression; + return expression != null ? new OrExpression(expression, inExpression) : inExpression; } /** diff --git a/continew-starter-extension/continew-starter-extension-tenant/continew-starter-extension-tenant-mp/src/main/java/top/continew/starter/extension/tenant/handler/line/DefaultTenantLineHandler.java b/continew-starter-extension/continew-starter-extension-tenant/continew-starter-extension-tenant-mp/src/main/java/top/continew/starter/extension/tenant/handler/line/DefaultTenantLineHandler.java index d432e209..f17e1269 100644 --- a/continew-starter-extension/continew-starter-extension-tenant/continew-starter-extension-tenant-mp/src/main/java/top/continew/starter/extension/tenant/handler/line/DefaultTenantLineHandler.java +++ b/continew-starter-extension/continew-starter-extension-tenant/continew-starter-extension-tenant-mp/src/main/java/top/continew/starter/extension/tenant/handler/line/DefaultTenantLineHandler.java @@ -41,7 +41,7 @@ public class DefaultTenantLineHandler implements TenantLineHandler { @Override public Expression getTenantId() { Long tenantId = TenantContextHolder.getTenantId(); - if (null != tenantId) { + if (tenantId != null) { return new LongValue(tenantId); } return null; @@ -55,7 +55,7 @@ public class DefaultTenantLineHandler implements TenantLineHandler { @Override public boolean ignoreTable(String tableName) { Long tenantId = TenantContextHolder.getTenantId(); - if (null != tenantId && tenantId.equals(tenantProperties.getSuperTenantId())) { + if (tenantId != null && tenantId.equals(tenantProperties.getSuperTenantId())) { return true; } if (TenantIsolationLevel.DATASOURCE.equals(TenantContextHolder.getIsolationLevel())) { diff --git a/continew-starter-file/continew-starter-file-excel/src/main/java/top/continew/starter/file/excel/converter/ExcelBigNumberConverter.java b/continew-starter-file/continew-starter-file-excel/src/main/java/top/continew/starter/file/excel/converter/ExcelBigNumberConverter.java index 59662fd0..0c8b943a 100644 --- a/continew-starter-file/continew-starter-file-excel/src/main/java/top/continew/starter/file/excel/converter/ExcelBigNumberConverter.java +++ b/continew-starter-file/continew-starter-file-excel/src/main/java/top/continew/starter/file/excel/converter/ExcelBigNumberConverter.java @@ -68,7 +68,7 @@ public class ExcelBigNumberConverter implements Converter { public WriteCellData convertToExcelData(Long value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { - if (null != value) { + if (value != null) { String str = Long.toString(value); if (str.length() > MAX_LENGTH) { return new WriteCellData<>(str); diff --git a/continew-starter-json/continew-starter-json-jackson/src/main/java/top/continew/starter/json/jackson/serializer/SimpleDeserializersWrapper.java b/continew-starter-json/continew-starter-json-jackson/src/main/java/top/continew/starter/json/jackson/serializer/SimpleDeserializersWrapper.java index 90899384..63b13aff 100644 --- a/continew-starter-json/continew-starter-json-jackson/src/main/java/top/continew/starter/json/jackson/serializer/SimpleDeserializersWrapper.java +++ b/continew-starter-json/continew-starter-json-jackson/src/main/java/top/continew/starter/json/jackson/serializer/SimpleDeserializersWrapper.java @@ -50,13 +50,13 @@ public class SimpleDeserializersWrapper extends SimpleDeserializers { DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { JsonDeserializer deser = super.findEnumDeserializer(type, config, beanDesc); - if (null != deser) { + if (deser != null) { return deser; } // 重写增强:开始查找指定枚举类型的接口的反序列化器(例如:GenderEnum 枚举类型,则是找它的接口 BaseEnum 的反序列化器) for (Class typeInterface : type.getInterfaces()) { deser = this._classMappings.get(new ClassKey(typeInterface)); - if (null != deser) { + if (deser != null) { return deser; } } diff --git a/continew-starter-log/continew-starter-log-core/src/main/java/top/continew/starter/log/handler/AbstractLogHandler.java b/continew-starter-log/continew-starter-log-core/src/main/java/top/continew/starter/log/handler/AbstractLogHandler.java index ac0807fa..d492d6bd 100644 --- a/continew-starter-log/continew-starter-log-core/src/main/java/top/continew/starter/log/handler/AbstractLogHandler.java +++ b/continew-starter-log/continew-starter-log-core/src/main/java/top/continew/starter/log/handler/AbstractLogHandler.java @@ -54,19 +54,19 @@ public abstract class AbstractLogHandler implements LogHandler { public boolean isRecord(Method targetMethod, Class targetClass) { // 如果接口被隐藏,不记录日志 Operation methodOperation = AnnotationUtil.getAnnotation(targetMethod, Operation.class); - if (null != methodOperation && methodOperation.hidden()) { + if (methodOperation != null && methodOperation.hidden()) { return false; } Hidden methodHidden = AnnotationUtil.getAnnotation(targetMethod, Hidden.class); - if (null != methodHidden) { + if (methodHidden != null) { return false; } - if (null != targetClass.getDeclaredAnnotation(Hidden.class)) { + if (targetClass.getDeclaredAnnotation(Hidden.class) != null) { return false; } // 如果接口方法或类上有 @Log 注解,且要求忽略该接口,则不记录日志 Log methodLog = AnnotationUtil.getAnnotation(targetMethod, Log.class); - if (null != methodLog && methodLog.ignore()) { + if (methodLog != null && methodLog.ignore()) { return false; } Log classLog = AnnotationUtil.getAnnotation(targetClass, Log.class); @@ -113,13 +113,13 @@ public abstract class AbstractLogHandler implements LogHandler { logRecord.setDescription("请在该接口方法上添加 @top.continew.starter.log.annotation.Log(value) 来指定日志描述"); Log methodLog = AnnotationUtil.getAnnotation(targetMethod, Log.class); // 例如:@Log("新增部门") -> 新增部门 - if (null != methodLog && CharSequenceUtil.isNotBlank(methodLog.value())) { + if (methodLog != null && CharSequenceUtil.isNotBlank(methodLog.value())) { logRecord.setDescription(methodLog.value()); return; } // 例如:@Operation(summary="新增部门") -> 新增部门 Operation methodOperation = AnnotationUtil.getAnnotation(targetMethod, Operation.class); - if (null != methodOperation && CharSequenceUtil.isNotBlank(methodOperation.summary())) { + if (methodOperation != null && CharSequenceUtil.isNotBlank(methodOperation.summary())) { logRecord.setDescription(methodOperation.summary()); } } @@ -137,18 +137,18 @@ public abstract class AbstractLogHandler implements LogHandler { Log methodLog = AnnotationUtil.getAnnotation(targetMethod, Log.class); // 例如:@Log(module = "部门管理") -> 部门管理 // 方法级注解优先级高于类级注解 - if (null != methodLog && CharSequenceUtil.isNotBlank(methodLog.module())) { + if (methodLog != null && CharSequenceUtil.isNotBlank(methodLog.module())) { logRecord.setModule(methodLog.module()); return; } Log classLog = AnnotationUtil.getAnnotation(targetClass, Log.class); - if (null != classLog && CharSequenceUtil.isNotBlank(classLog.module())) { + if (classLog != null && CharSequenceUtil.isNotBlank(classLog.module())) { logRecord.setModule(classLog.module()); return; } // 例如:@Tag(name = "部门管理") -> 部门管理 Tag classTag = AnnotationUtil.getAnnotation(targetClass, Tag.class); - if (null != classTag && CharSequenceUtil.isNotBlank(classTag.name())) { + if (classTag != null && CharSequenceUtil.isNotBlank(classTag.name())) { logRecord.setModule(classTag.name()); } } @@ -157,12 +157,12 @@ public abstract class AbstractLogHandler implements LogHandler { public Set getIncludes(Set includes, Method targetMethod, Class targetClass) { Log classLog = AnnotationUtil.getAnnotation(targetClass, Log.class); Set includeSet = new HashSet<>(includes); - if (null != classLog) { + if (classLog != null) { this.processInclude(includeSet, classLog); } // 方法级注解优先级高于类级注解 Log methodLog = AnnotationUtil.getAnnotation(targetMethod, Log.class); - if (null != methodLog) { + if (methodLog != null) { this.processInclude(includeSet, methodLog); } return includeSet; diff --git a/continew-starter-security/continew-starter-security-crypto/src/main/java/top/continew/starter/security/crypto/core/AbstractMyBatisInterceptor.java b/continew-starter-security/continew-starter-security-crypto/src/main/java/top/continew/starter/security/crypto/core/AbstractMyBatisInterceptor.java index b9b9c8d6..8327e137 100644 --- a/continew-starter-security/continew-starter-security-crypto/src/main/java/top/continew/starter/security/crypto/core/AbstractMyBatisInterceptor.java +++ b/continew-starter-security/continew-starter-security-crypto/src/main/java/top/continew/starter/security/crypto/core/AbstractMyBatisInterceptor.java @@ -67,7 +67,7 @@ public abstract class AbstractMyBatisInterceptor { protected List getEncryptFields(Class clazz) { return CLASS_FIELD_CACHE.computeIfAbsent(clazz, key -> Arrays.stream(ReflectUtil.getFields(clazz)) .filter(field -> String.class.equals(field.getType())) - .filter(field -> null != field.getAnnotation(FieldEncrypt.class)) + .filter(field -> field.getAnnotation(FieldEncrypt.class) != null) .toList()); } @@ -144,6 +144,6 @@ public abstract class AbstractMyBatisInterceptor { */ public String getParameterName(Parameter parameter) { Param param = parameter.getAnnotation(Param.class); - return null != param ? param.value() : parameter.getName(); + return param != null ? param.value() : parameter.getName(); } } \ No newline at end of file diff --git a/continew-starter-security/continew-starter-security-crypto/src/main/java/top/continew/starter/security/crypto/core/MyBatisEncryptInterceptor.java b/continew-starter-security/continew-starter-security-crypto/src/main/java/top/continew/starter/security/crypto/core/MyBatisEncryptInterceptor.java index 3f782610..9474f334 100644 --- a/continew-starter-security/continew-starter-security-crypto/src/main/java/top/continew/starter/security/crypto/core/MyBatisEncryptInterceptor.java +++ b/continew-starter-security/continew-starter-security-crypto/src/main/java/top/continew/starter/security/crypto/core/MyBatisEncryptInterceptor.java @@ -96,11 +96,11 @@ public class MyBatisEncryptInterceptor extends AbstractMyBatisInterceptor implem private void encryptMap(Map parameterMap, MappedStatement mappedStatement) { Object parameter; // 别名带有 et(针对 MP 的 updateById、update 等方法) - if (parameterMap.containsKey(Constants.ENTITY) && null != (parameter = parameterMap.get(Constants.ENTITY))) { + if (parameterMap.containsKey(Constants.ENTITY) && (parameter = parameterMap.get(Constants.ENTITY)) != null) { this.encryptEntity(super.getEncryptFields(parameter), parameter); } // 别名带有 ew(针对 MP 的 UpdateWrapper、LambdaUpdateWrapper 等参数) - if (parameterMap.containsKey(Constants.WRAPPER) && null != (parameter = parameterMap.get(Constants.WRAPPER))) { + if (parameterMap.containsKey(Constants.WRAPPER) && (parameter = parameterMap.get(Constants.WRAPPER)) != null) { this.encryptUpdateWrapper(parameter, mappedStatement); } } @@ -122,7 +122,7 @@ public class MyBatisEncryptInterceptor extends AbstractMyBatisInterceptor implem } if (parameterValue instanceof String str) { FieldEncrypt fieldEncrypt = encryptParameterMap.get(parameterName); - if (null != fieldEncrypt) { + if (fieldEncrypt != null) { parameterMap.put(parameterName, this.doEncrypt(str, fieldEncrypt)); } } else { diff --git a/continew-starter-web/src/main/java/top/continew/starter/web/util/SpringWebUtils.java b/continew-starter-web/src/main/java/top/continew/starter/web/util/SpringWebUtils.java index 36fefed7..f98e6e70 100644 --- a/continew-starter-web/src/main/java/top/continew/starter/web/util/SpringWebUtils.java +++ b/continew-starter-web/src/main/java/top/continew/starter/web/util/SpringWebUtils.java @@ -123,7 +123,8 @@ public class SpringWebUtils { final ResourceHandlerRegistry resourceHandlerRegistry = new ResourceHandlerRegistry(applicationContext, servletContext, contentNegotiationManager, urlPathHelper); for (Map.Entry entry : handlerMap.entrySet()) { // 移除之前注册的映射 - String pathPattern = CharSequenceUtil.appendIfMissing(CharSequenceUtil.removeSuffix(entry.getKey(), StringConstants.SLASH), StringConstants.PATH_PATTERN); + String pathPattern = CharSequenceUtil.appendIfMissing(CharSequenceUtil.removeSuffix(entry + .getKey(), StringConstants.SLASH), StringConstants.PATH_PATTERN); oldHandlerMap.remove(pathPattern); // 重新注册映射 String resourceLocations = CharSequenceUtil.appendIfMissing(entry.getValue(), StringConstants.SLASH);