mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 09:08:24 +08:00
refactor: 将不为 null 的判断统一到 QueryColumnBehavior 中。
This commit is contained in:
parent
36ed6c52fa
commit
2f5200f181
@ -15,24 +15,30 @@
|
|||||||
*/
|
*/
|
||||||
package com.mybatisflex.core.query;
|
package com.mybatisflex.core.query;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 默认 {@link QueryColumn} 行为。
|
||||||
|
*
|
||||||
* @author michael
|
* @author michael
|
||||||
|
* @author 王帅
|
||||||
*/
|
*/
|
||||||
public class QueryColumnBehavior {
|
public class QueryColumnBehavior {
|
||||||
|
|
||||||
/**
|
private QueryColumnBehavior() {
|
||||||
* 自定义全局的自动忽略参数的方法
|
}
|
||||||
*/
|
|
||||||
private static Predicate<Object> ignoreFunction;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否自动把 in(...) 只有 1 个参数的内容转换为相等 =
|
* 自定义全局的自动忽略参数的方法。
|
||||||
|
*/
|
||||||
|
private static Predicate<Object> ignoreFunction = Objects::isNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当 {@code IN(...)} 条件只有 1 个参数时,是否自动把的内容转换为相等。
|
||||||
*/
|
*/
|
||||||
private static boolean smartConvertInToEquals = false;
|
private static boolean smartConvertInToEquals = false;
|
||||||
|
|
||||||
|
|
||||||
public static Predicate<Object> getIgnoreFunction() {
|
public static Predicate<Object> getIgnoreFunction() {
|
||||||
return ignoreFunction;
|
return ignoreFunction;
|
||||||
}
|
}
|
||||||
@ -49,11 +55,7 @@ public class QueryColumnBehavior {
|
|||||||
QueryColumnBehavior.smartConvertInToEquals = smartConvertInToEquals;
|
QueryColumnBehavior.smartConvertInToEquals = smartConvertInToEquals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static boolean shouldIgnoreValue(Object value) {
|
static boolean shouldIgnoreValue(Object value) {
|
||||||
if (ignoreFunction == null){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return ignoreFunction.test(value);
|
return ignoreFunction.test(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user