style: 调整代码风格 null != xx => xx != null(更符合大众风格)

This commit is contained in:
2025-05-17 13:50:59 +08:00
parent 49bd289e29
commit ae7a267c1d
19 changed files with 49 additions and 48 deletions

View File

@@ -67,7 +67,7 @@ public abstract class AbstractMyBatisInterceptor {
protected List<Field> 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();
}
}

View File

@@ -96,11 +96,11 @@ public class MyBatisEncryptInterceptor extends AbstractMyBatisInterceptor implem
private void encryptMap(Map<String, Object> 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 {