mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-09 04:59:21 +08:00
style: 调整代码风格 null == xx => xx == null(更符合大众风格)
This commit is contained in:
@@ -45,7 +45,7 @@ public class ExceptionUtils {
|
||||
* @param throwable 异常
|
||||
*/
|
||||
public static void printException(Runnable runnable, Throwable throwable) {
|
||||
if (null == throwable && runnable instanceof Future<?> future) {
|
||||
if (throwable == null && runnable instanceof Future<?> future) {
|
||||
try {
|
||||
if (future.isDone()) {
|
||||
future.get();
|
||||
|
@@ -50,7 +50,7 @@ public class IpUtils {
|
||||
}
|
||||
Ip2regionSearcher ip2regionSearcher = SpringUtil.getBean(Ip2regionSearcher.class);
|
||||
IpInfo ipInfo = ip2regionSearcher.memorySearch(ip);
|
||||
if (null == ipInfo) {
|
||||
if (ipInfo == null) {
|
||||
return null;
|
||||
}
|
||||
Set<String> regionSet = CollUtil.newLinkedHashSet(ipInfo.getCountry(), ipInfo.getRegion(), ipInfo
|
||||
|
@@ -57,7 +57,7 @@ public class ServletUtils extends JakartaServletUtil {
|
||||
* @return 浏览器及其版本信息
|
||||
*/
|
||||
public static String getBrowser(HttpServletRequest request) {
|
||||
if (null == request) {
|
||||
if (request == null) {
|
||||
return null;
|
||||
}
|
||||
return getBrowser(request.getHeader("User-Agent"));
|
||||
@@ -90,7 +90,7 @@ public class ServletUtils extends JakartaServletUtil {
|
||||
* @return 操作系统
|
||||
*/
|
||||
public static String getOs(HttpServletRequest request) {
|
||||
if (null == request) {
|
||||
if (request == null) {
|
||||
return null;
|
||||
}
|
||||
return getOs(request.getHeader("User-Agent"));
|
||||
|
@@ -48,7 +48,7 @@ public class Validator {
|
||||
* @param exceptionType 异常类型
|
||||
*/
|
||||
protected static void throwIfNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
|
||||
throwIf(null == obj, message, exceptionType);
|
||||
throwIf(obj == null, message, exceptionType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -57,7 +57,7 @@ public class MetaUtils {
|
||||
*/
|
||||
public static DatabaseType getDatabaseTypeOrDefault(DataSource dataSource, DatabaseType defaultValue) {
|
||||
DatabaseType databaseType = getDatabaseType(dataSource);
|
||||
return null == databaseType ? defaultValue : databaseType;
|
||||
return databaseType == null ? defaultValue : databaseType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -43,7 +43,7 @@ public class DataPermissionDialect extends CommonsDialectImpl {
|
||||
return super.buildSelectSql(queryWrapper);
|
||||
}
|
||||
DataPermission dataPermission = DataPermissionAspect.currentDataPermission();
|
||||
if (null == dataPermission) {
|
||||
if (dataPermission == null) {
|
||||
return super.buildSelectSql(queryWrapper);
|
||||
}
|
||||
DataPermissionCurrentUser currentUser = dataPermissionFilter.getCurrentUser();
|
||||
|
@@ -65,7 +65,7 @@ public class QueryWrapperHelper {
|
||||
public static <Q> QueryWrapper build(Q query) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create();
|
||||
// 没有查询条件,直接返回
|
||||
if (null == query) {
|
||||
if (query == null) {
|
||||
return queryWrapper;
|
||||
}
|
||||
// 获取查询条件中所有的字段
|
||||
@@ -85,7 +85,7 @@ public class QueryWrapperHelper {
|
||||
public static <Q> QueryWrapper build(Q query, Sort sort) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create();
|
||||
// 没有查询条件,直接返回
|
||||
if (null == query) {
|
||||
if (query == null) {
|
||||
return queryWrapper;
|
||||
}
|
||||
// 设置排序条件
|
||||
@@ -112,7 +112,7 @@ public class QueryWrapperHelper {
|
||||
*/
|
||||
public static <Q> QueryWrapper build(Q query, List<Field> fields, QueryWrapper queryWrapper) {
|
||||
// 没有查询条件,直接返回
|
||||
if (null == query) {
|
||||
if (query == null) {
|
||||
return queryWrapper;
|
||||
}
|
||||
// 解析并拼接查询条件
|
||||
@@ -150,7 +150,7 @@ public class QueryWrapperHelper {
|
||||
String fieldName = ReflectUtil.getFieldName(field);
|
||||
// 没有 @Query 注解,默认等值查询
|
||||
Query queryAnnotation = AnnotationUtil.getAnnotation(field, Query.class);
|
||||
if (null == queryAnnotation) {
|
||||
if (queryAnnotation == null) {
|
||||
return Collections.singletonList(q -> q.eq(CharSequenceUtil.toUnderlineCase(fieldName), fieldValue));
|
||||
}
|
||||
// 解析单列查询
|
||||
|
@@ -121,7 +121,7 @@ public class MybatisBaseEnumTypeHandler<E extends Enum<E>> extends BaseTypeHandl
|
||||
@Override
|
||||
public E getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
Object value = rs.getObject(columnName, this.propertyType);
|
||||
if (null == value || rs.wasNull()) {
|
||||
if (value == null || rs.wasNull()) {
|
||||
return null;
|
||||
}
|
||||
return this.valueOf(value);
|
||||
@@ -130,7 +130,7 @@ public class MybatisBaseEnumTypeHandler<E extends Enum<E>> extends BaseTypeHandl
|
||||
@Override
|
||||
public E getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
Object value = rs.getObject(columnIndex, this.propertyType);
|
||||
if (null == value || rs.wasNull()) {
|
||||
if (value == null || rs.wasNull()) {
|
||||
return null;
|
||||
}
|
||||
return this.valueOf(value);
|
||||
@@ -139,7 +139,7 @@ public class MybatisBaseEnumTypeHandler<E extends Enum<E>> extends BaseTypeHandl
|
||||
@Override
|
||||
public E getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
Object value = cs.getObject(columnIndex, this.propertyType);
|
||||
if (null == value || cs.wasNull()) {
|
||||
if (value == null || cs.wasNull()) {
|
||||
return null;
|
||||
}
|
||||
return this.valueOf(value);
|
||||
|
@@ -97,7 +97,7 @@ public class QueryWrapperHelper {
|
||||
public static <Q, R> QueryWrapper<R> build(Q query, Sort sort) {
|
||||
QueryWrapper<R> queryWrapper = new QueryWrapper<>();
|
||||
// 没有查询条件,直接返回
|
||||
if (null == query) {
|
||||
if (query == null) {
|
||||
return queryWrapper;
|
||||
}
|
||||
// 设置排序条件
|
||||
@@ -125,7 +125,7 @@ public class QueryWrapperHelper {
|
||||
*/
|
||||
public static <Q, R> QueryWrapper<R> build(Q query, List<Field> fields, QueryWrapper<R> queryWrapper) {
|
||||
// 没有查询条件,直接返回
|
||||
if (null == query) {
|
||||
if (query == null) {
|
||||
return queryWrapper;
|
||||
}
|
||||
// 解析并拼接查询条件
|
||||
@@ -161,7 +161,7 @@ public class QueryWrapperHelper {
|
||||
String fieldName = ReflectUtil.getFieldName(field);
|
||||
// 没有 @Query 注解,默认等值查询
|
||||
Query queryAnnotation = AnnotationUtil.getAnnotation(field, Query.class);
|
||||
if (null == queryAnnotation) {
|
||||
if (queryAnnotation == null) {
|
||||
return Collections.singletonList(q -> q.eq(CharSequenceUtil.toUnderlineCase(fieldName), fieldValue));
|
||||
}
|
||||
// 解析单列查询
|
||||
|
@@ -42,7 +42,7 @@ public class CrudRequestMappingHandlerMapping extends RequestMappingHandlerMappi
|
||||
@Override
|
||||
protected RequestMappingInfo getMappingForMethod(@NonNull Method method, @NonNull Class<?> handlerType) {
|
||||
RequestMappingInfo requestMappingInfo = super.getMappingForMethod(method, handlerType);
|
||||
if (null == requestMappingInfo) {
|
||||
if (requestMappingInfo == null) {
|
||||
return null;
|
||||
}
|
||||
// 如果没有声明 @CrudRequestMapping 注解,直接返回
|
||||
|
@@ -56,7 +56,7 @@ public class PageResp<L> extends BasePageResp<L> {
|
||||
* @return 分页信息
|
||||
*/
|
||||
public static <T, L> PageResp<L> build(Page<T> page, Class<L> targetClass) {
|
||||
if (null == page) {
|
||||
if (page == null) {
|
||||
return empty();
|
||||
}
|
||||
return new PageResp<>(BeanUtil.copyToList(page.getRecords(), targetClass), page.getTotalRow());
|
||||
@@ -70,7 +70,7 @@ public class PageResp<L> extends BasePageResp<L> {
|
||||
* @return 分页信息
|
||||
*/
|
||||
public static <L> PageResp<L> build(Page<L> page) {
|
||||
if (null == page) {
|
||||
if (page == null) {
|
||||
return empty();
|
||||
}
|
||||
return new PageResp<>(page.getRecords(), page.getTotalRow());
|
||||
|
@@ -220,7 +220,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseIdD
|
||||
* @param obj 待填充信息
|
||||
*/
|
||||
protected void fill(Object obj) {
|
||||
if (null == obj) {
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
OperateTemplate operateTemplate = SpringUtil.getBean(OperateTemplate.class);
|
||||
|
@@ -56,7 +56,7 @@ public class PageResp<L> extends BasePageResp<L> {
|
||||
* @return 分页信息
|
||||
*/
|
||||
public static <T, L> PageResp<L> build(IPage<T> page, Class<L> targetClass) {
|
||||
if (null == page) {
|
||||
if (page == null) {
|
||||
return empty();
|
||||
}
|
||||
return new PageResp<>(BeanUtil.copyToList(page.getRecords(), targetClass), page.getTotal());
|
||||
@@ -70,7 +70,7 @@ public class PageResp<L> extends BasePageResp<L> {
|
||||
* @return 分页信息
|
||||
*/
|
||||
public static <L> PageResp<L> build(IPage<L> page) {
|
||||
if (null == page) {
|
||||
if (page == null) {
|
||||
return empty();
|
||||
}
|
||||
return new PageResp<>(page.getRecords(), page.getTotal());
|
||||
|
@@ -311,7 +311,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseIdD
|
||||
* @param obj 待填充信息
|
||||
*/
|
||||
protected void fill(Object obj) {
|
||||
if (null == obj) {
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
OperateTemplate operateTemplate = SpringUtil.getBean(OperateTemplate.class);
|
||||
|
@@ -82,7 +82,7 @@ public class DefaultDataPermissionHandler implements DataPermissionHandler {
|
||||
for (Method method : methodArr) {
|
||||
DataPermission dataPermission = method.getAnnotation(DataPermission.class);
|
||||
String name = method.getName();
|
||||
if (null == dataPermission || !CharSequenceUtil.equalsAny(methodName, name, name + "_COUNT")) {
|
||||
if (dataPermission == null || !CharSequenceUtil.equalsAny(methodName, name, name + "_COUNT")) {
|
||||
continue;
|
||||
}
|
||||
if (dataPermissionUserContextProvider.isFilter()) {
|
||||
|
@@ -61,7 +61,7 @@ public class ExcelBaseEnumConverter implements Converter<BaseEnum<?>> {
|
||||
public WriteCellData<String> convertToExcelData(BaseEnum<?> value,
|
||||
ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
if (null == value) {
|
||||
if (value == null) {
|
||||
return new WriteCellData<>(StringConstants.EMPTY);
|
||||
}
|
||||
return new WriteCellData<>(value.getDescription());
|
||||
|
@@ -70,7 +70,7 @@ public abstract class AbstractLogHandler implements LogHandler {
|
||||
return false;
|
||||
}
|
||||
Log classLog = AnnotationUtil.getAnnotation(targetClass, Log.class);
|
||||
return null == classLog || !classLog.ignore();
|
||||
return classLog == null || !classLog.ignore();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -93,7 +93,7 @@ public class LogRequest {
|
||||
this.address = (includes.contains(Include.IP_ADDRESS))
|
||||
? ExceptionUtils.exToNull(() -> IpUtils.getIpv4Address(this.ip))
|
||||
: null;
|
||||
if (null == this.headers) {
|
||||
if (this.headers == null) {
|
||||
return;
|
||||
}
|
||||
String userAgentString = this.headers.entrySet()
|
||||
|
@@ -76,7 +76,7 @@ public class LogInterceptor implements HandlerInterceptor {
|
||||
Instant endTime = Instant.now();
|
||||
logHandler.accessLogFinish(AccessLogContext.builder().endTime(endTime).build());
|
||||
LogRecord.Started startedLogRecord = logTtl.get();
|
||||
if (null == startedLogRecord) {
|
||||
if (startedLogRecord == null) {
|
||||
return;
|
||||
}
|
||||
// 结束日志记录
|
||||
|
@@ -52,7 +52,7 @@ public abstract class AbstractMyBatisInterceptor {
|
||||
* @return 字段列表
|
||||
*/
|
||||
protected List<Field> getEncryptFields(Object obj) {
|
||||
if (null == obj) {
|
||||
if (obj == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return this.getEncryptFields(obj.getClass());
|
||||
@@ -98,7 +98,7 @@ public abstract class AbstractMyBatisInterceptor {
|
||||
String mappedStatementId = mappedStatement.getId();
|
||||
return ENCRYPT_PARAM_CACHE.computeIfAbsent(mappedStatementId, key -> {
|
||||
Method method = this.getMethod(mappedStatementId);
|
||||
if (null == method) {
|
||||
if (method == null) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String, FieldEncrypt> encryptMap = new HashMap<>();
|
||||
@@ -106,7 +106,7 @@ public abstract class AbstractMyBatisInterceptor {
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
Parameter parameter = parameters[i];
|
||||
FieldEncrypt fieldEncrypt = parameter.getAnnotation(FieldEncrypt.class);
|
||||
if (null == fieldEncrypt) {
|
||||
if (fieldEncrypt == null) {
|
||||
continue;
|
||||
}
|
||||
String parameterName = this.getParameterName(parameter);
|
||||
|
@@ -68,7 +68,7 @@ public class JsonMaskSerializer extends JsonSerializer<String> implements Contex
|
||||
@Override
|
||||
public JsonSerializer<?> createContextual(SerializerProvider serializerProvider,
|
||||
BeanProperty beanProperty) throws JsonMappingException {
|
||||
if (null == beanProperty) {
|
||||
if (beanProperty == null) {
|
||||
return serializerProvider.findNullValueSerializer(null);
|
||||
}
|
||||
if (!Objects.equals(beanProperty.getType().getRawClass(), String.class)) {
|
||||
@@ -76,7 +76,7 @@ public class JsonMaskSerializer extends JsonSerializer<String> implements Contex
|
||||
}
|
||||
JsonMask jsonMaskAnnotation = ObjectUtil.defaultIfNull(beanProperty.getAnnotation(JsonMask.class), beanProperty
|
||||
.getContextAnnotation(JsonMask.class));
|
||||
if (null == jsonMaskAnnotation) {
|
||||
if (jsonMaskAnnotation == null) {
|
||||
return serializerProvider.findValueSerializer(beanProperty.getType(), beanProperty);
|
||||
}
|
||||
return new JsonMaskSerializer(jsonMaskAnnotation);
|
||||
|
Reference in New Issue
Block a user