Skip to content

Commit ae7a267

Browse files
committed
style: 调整代码风格 null != xx => xx != null(更符合大众风格)
1 parent 49bd289 commit ae7a267

File tree

19 files changed

+49
-48
lines changed

19 files changed

+49
-48
lines changed

continew-starter-api-doc/src/main/java/top/continew/starter/apidoc/autoconfigure/SpringDocAutoConfiguration.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,17 @@ public OpenAPI openApi(ProjectProperties projectProperties, SpringDocExtensionPr
8787
.version(projectProperties.getVersion())
8888
.description(projectProperties.getDescription());
8989
ProjectProperties.Contact contact = projectProperties.getContact();
90-
if (null != contact) {
90+
if (contact != null) {
9191
info.contact(new Contact().name(contact.getName()).email(contact.getEmail()).url(contact.getUrl()));
9292
}
9393
ProjectProperties.License license = projectProperties.getLicense();
94-
if (null != license) {
94+
if (license != null) {
9595
info.license(new License().name(license.getName()).url(license.getUrl()));
9696
}
9797
OpenAPI openApi = new OpenAPI();
9898
openApi.info(info);
9999
Components components = properties.getComponents();
100-
if (null != components) {
100+
if (components != null) {
101101
openApi.components(components);
102102
// 鉴权配置
103103
Map<String, SecurityScheme> securitySchemeMap = components.getSecuritySchemes();
@@ -118,11 +118,11 @@ public OpenAPI openApi(ProjectProperties projectProperties, SpringDocExtensionPr
118118
@ConditionalOnMissingBean
119119
public GlobalOpenApiCustomizer globalOpenApiCustomizer(SpringDocExtensionProperties properties) {
120120
return openApi -> {
121-
if (null != openApi.getPaths()) {
121+
if (openApi.getPaths() != null) {
122122
openApi.getPaths().forEach((s, pathItem) -> {
123123
// 为所有接口添加鉴权
124124
Components components = properties.getComponents();
125-
if (null != components && MapUtil.isNotEmpty(components.getSecuritySchemes())) {
125+
if (components != null && MapUtil.isNotEmpty(components.getSecuritySchemes())) {
126126
Map<String, SecurityScheme> securitySchemeMap = components.getSecuritySchemes();
127127
pathItem.readOperations().forEach(operation -> {
128128
SecurityRequirement securityRequirement = new SecurityRequirement();

continew-starter-cache/continew-starter-cache-redisson/src/main/java/top/continew/starter/cache/redisson/autoconfigure/RedissonAutoConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public RedissonAutoConfigurationCustomizer redissonAutoConfigurationCustomizer()
9393
private void buildClusterModeConfig(Config config, String protocolPrefix) {
9494
ClusterServersConfig clusterServersConfig = config.useClusterServers();
9595
ClusterServersConfig customClusterServersConfig = properties.getClusterServersConfig();
96-
if (null != customClusterServersConfig) {
96+
if (customClusterServersConfig != null) {
9797
BeanUtil.copyProperties(customClusterServersConfig, clusterServersConfig);
9898
clusterServersConfig.setNodeAddresses(customClusterServersConfig.getNodeAddresses());
9999
}
@@ -122,7 +122,7 @@ private void buildClusterModeConfig(Config config, String protocolPrefix) {
122122
private void buildSentinelModeConfig(Config config, String protocolPrefix) {
123123
SentinelServersConfig sentinelServersConfig = config.useSentinelServers();
124124
SentinelServersConfig customSentinelServersConfig = properties.getSentinelServersConfig();
125-
if (null != customSentinelServersConfig) {
125+
if (customSentinelServersConfig != null) {
126126
BeanUtil.copyProperties(customSentinelServersConfig, sentinelServersConfig);
127127
sentinelServersConfig.setSentinelAddresses(customSentinelServersConfig.getSentinelAddresses());
128128
}
@@ -154,7 +154,7 @@ private void buildSentinelModeConfig(Config config, String protocolPrefix) {
154154
private void buildSingleModeConfig(Config config, String protocolPrefix) {
155155
SingleServerConfig singleServerConfig = config.useSingleServer();
156156
SingleServerConfig customSingleServerConfig = properties.getSingleServerConfig();
157-
if (null != customSingleServerConfig) {
157+
if (customSingleServerConfig != null) {
158158
BeanUtil.copyProperties(properties.getSingleServerConfig(), singleServerConfig);
159159
}
160160
// 下方配置如果为空,则使用 Redis 的配置

continew-starter-cache/continew-starter-cache-springcache/src/main/java/top/continew/starter/cache/springcache/autoconfigure/SpringCacheAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public RedisCacheConfiguration redisCacheConfiguration(CacheProperties cacheProp
7272
.serializeValuesWith(RedisSerializationContext.SerializationPair
7373
.fromSerializer(new GenericJackson2JsonRedisSerializer(objectMapperCopy)));
7474
CacheProperties.Redis redisCacheProperties = cacheProperties.getRedis();
75-
if (null != redisCacheProperties.getTimeToLive()) {
75+
if (redisCacheProperties.getTimeToLive() != null) {
7676
redisCacheConfiguration = redisCacheConfiguration.entryTtl(redisCacheProperties.getTimeToLive());
7777
}
7878
if (!redisCacheProperties.isCacheNullValues()) {

continew-starter-core/src/main/java/top/continew/starter/core/constant/StringConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public class StringConstants {
115115
public static final String SLASH = "/";
116116

117117
/**
118-
* 双斜杠 {@code "//"}
118+
* 双斜杠 {@code "//"}
119119
*/
120120
public static final String DOUBLE_SLASH = "//";
121121

continew-starter-core/src/main/java/top/continew/starter/core/util/ExceptionUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static void printException(Runnable runnable, Throwable throwable) {
5757
Thread.currentThread().interrupt();
5858
}
5959
}
60-
if (null != throwable) {
60+
if (throwable != null) {
6161
log.error(throwable.getMessage(), throwable);
6262
}
6363
}
@@ -120,7 +120,7 @@ public static <T> T exToDefault(ExSupplier<T> exSupplier, T defaultValue, Consum
120120
try {
121121
return exSupplier.get();
122122
} catch (Exception e) {
123-
if (null != exConsumer) {
123+
if (exConsumer != null) {
124124
exConsumer.accept(e);
125125
}
126126
return defaultValue;

continew-starter-core/src/main/java/top/continew/starter/core/validation/Validator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected static void throwIfNull(Object obj, String message, Class<? extends Ru
5959
* @param exceptionType 异常类型
6060
*/
6161
protected static void throwIfNotNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
62-
throwIf(null != obj, message, exceptionType);
62+
throwIf(obj != null, message, exceptionType);
6363
}
6464

6565
/**
@@ -193,7 +193,7 @@ protected static void throwIf(boolean condition, String message, Class<? extends
193193
protected static void throwIf(BooleanSupplier conditionSupplier,
194194
String message,
195195
Class<? extends RuntimeException> exceptionType) {
196-
if (null != conditionSupplier && conditionSupplier.getAsBoolean()) {
196+
if (conditionSupplier != null && conditionSupplier.getAsBoolean()) {
197197
throw ReflectUtil.newInstance(exceptionType, message);
198198
}
199199
}

continew-starter-data/continew-starter-data-core/src/main/java/top/continew/starter/data/core/util/MetaUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public static List<Table> getTables(DataSource dataSource, String tableName) {
106106
final DatabaseMetaData metaData = conn.getMetaData();
107107
try (final ResultSet rs = metaData.getTables(catalog, schema, tableName, Convert
108108
.toStrArray(TableType.TABLE))) {
109-
if (null != rs) {
109+
if (rs != null) {
110110
String name;
111111
while (rs.next()) {
112112
name = rs.getString("TABLE_NAME");

continew-starter-data/continew-starter-data-mf/src/main/java/top/continew/starter/data/mf/util/QueryWrapperHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private static <Q, R> List<Consumer<QueryWrapper>> buildWrapperConsumer(Q query,
143143
}
144144
// 设置了 @QueryIgnore 注解,直接忽略
145145
QueryIgnore queryIgnoreAnnotation = AnnotationUtil.getAnnotation(field, QueryIgnore.class);
146-
if (null != queryIgnoreAnnotation) {
146+
if (queryIgnoreAnnotation != null) {
147147
return Collections.emptyList();
148148
}
149149
// 建议:数据库表列建议采用下划线连接法命名,程序变量建议采用驼峰法命名

continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/autoconfigure/MybatisPlusAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public MybatisPlusInterceptor mybatisPlusInterceptor(MyBatisPlusExtensionPropert
8484
}
8585
// 分页插件
8686
MyBatisPlusExtensionProperties.PaginationProperties paginationProperties = properties.getPagination();
87-
if (null != paginationProperties && paginationProperties.isEnabled()) {
87+
if (paginationProperties != null && paginationProperties.isEnabled()) {
8888
interceptor.addInnerInterceptor(this.paginationInnerInterceptor(paginationProperties));
8989
}
9090
// 乐观锁插件

continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/util/QueryWrapperHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private static <Q, R> List<Consumer<QueryWrapper<R>>> buildWrapperConsumer(Q que
154154
}
155155
// 设置了 @QueryIgnore 注解,直接忽略
156156
QueryIgnore queryIgnoreAnnotation = AnnotationUtil.getAnnotation(field, QueryIgnore.class);
157-
if (null != queryIgnoreAnnotation) {
157+
if (queryIgnoreAnnotation != null) {
158158
return Collections.emptyList();
159159
}
160160
// 建议:数据库表列建议采用下划线连接法命名,程序变量建议采用驼峰法命名

0 commit comments

Comments
 (0)