remove: 移除可能出现泛型错误的代码。

This commit is contained in:
Suomm 2023-08-25 14:54:37 +08:00
parent 24ab62e615
commit c7089b55b3

View File

@ -27,7 +27,6 @@ import com.mybatisflex.core.util.StringUtil;
import java.lang.reflect.Array;
import java.util.List;
import java.util.function.BooleanSupplier;
import java.util.function.Predicate;
public class QueryCondition implements CloneSupport<QueryCondition> {
@ -126,38 +125,6 @@ public class QueryCondition implements CloneSupport<QueryCondition> {
return this;
}
/**
* <p>动态条件构造
*
* <p>推荐将 {@link Predicate} 推断写在填写的值的后面以确保泛型对应例如
* <pre>{@code
* ACCOUNT.ID.in(idList, CollectionUtil::isNotEmpty);
* }</pre>
*
* @see #when(boolean)
* @see #when(BooleanSupplier)
* @deprecated 由于 {@link QueryCondition} 中属性 {@link #value} 的类型为 Object
* 类型没有使用泛型所以该方法泛型推断可能会出现问题
*/
@Deprecated
@SuppressWarnings("unchecked")
public <T> QueryCondition when(Predicate<T> fn) {
Object val = this.value;
if ((SqlConsts.LIKE.equals(logic) || SqlConsts.NOT_LIKE.equals(logic))
&& val instanceof String) {
String valStr = (String) val;
if (valStr.startsWith(SqlConsts.PERCENT_SIGN)) {
valStr = valStr.substring(1);
}
if (valStr.endsWith(SqlConsts.PERCENT_SIGN)) {
valStr = valStr.substring(0, valStr.length() - 1);
}
val = valStr;
}
this.effective = fn.test((T) val);
return this;
}
public boolean checkEffective() {
return effective;
}