
cn.org.atool.fluent.mybatis.segment.where.BaseWhere Maven / Gradle / Ivy
package cn.org.atool.fluent.mybatis.segment.where;
import cn.org.atool.fluent.mybatis.base.crud.IBaseQuery;
import cn.org.atool.fluent.mybatis.base.model.ISqlOp;
import cn.org.atool.fluent.mybatis.ifs.Ifs;
import cn.org.atool.fluent.mybatis.segment.WhereBase;
import java.util.function.Predicate;
import static cn.org.atool.fluent.mybatis.base.model.SqlOp.*;
/**
* 基础比较: apply, is null, not null, eq, ne
*
* @param
* @param
*/
@SuppressWarnings({"unchecked", "unused"})
public interface BaseWhere<
WHERE extends WhereBase,
NQ extends IBaseQuery, NQ>
> {
/**
* is null
*
* @return 查询器或更新器
*/
default WHERE isNull() {
return this.apply(IS_NULL);
}
/**
* is null
*
* @param condition 条件为真时成立
* @return 查询器或更新器
*/
default WHERE isNull(boolean condition) {
return this.apply(args -> condition, IS_NULL);
}
/**
* not null
*
* @return 查询器或更新器
*/
default WHERE notNull() {
return this.apply(NOT_NULL);
}
/**
* not null
*
* @param condition 条件为真时成立
* @return 查询器或更新器
*/
default WHERE notNull(boolean condition) {
return this.apply(args -> condition, NOT_NULL);
}
/**
* 等于 =
*
* @param value 条件值
* @return 查询器或更新器
*/
default WHERE eq(T value) {
return this.apply(EQ, value);
}
/**
* 按Ifs条件设置where值
*
* @param ifs 条件
* @param 类型
* @return ignore
*/
default WHERE eq(Ifs ifs) {
return this.apply(EQ, ifs);
}
/**
* 等于 =, 值不为空时成立
*
* @param value 条件值
* @param when 条件为真时成立
* @return 查询器或更新器
*/
default WHERE eq(T value, Predicate when) {
return this.apply(args -> when.test(value), EQ, value);
}
/**
* 不等于 !=
*
* @param value 条件值
* @return 查询器或更新器
*/
default WHERE ne(T value) {
return this.apply(NE, value);
}
/**
* 不等于 !=
*
* @param value 条件值
* @param when 为真时成立
* @return 查询器或更新器
*/
default WHERE ne(T value, Predicate when) {
return this.apply(args -> when.test(value), NE, value);
}
/**
* 按Ifs条件设置where值
*
* @param ifs 条件
* @param 类型
* @return ignore
*/
default WHERE ne(Ifs ifs) {
return this.apply(NE, ifs);
}
WHERE apply(ISqlOp op, T... args);
/**
* 多条件操作
*
* @param op 操作符
* @param ifs 条件
* @param 类型
* @return ignore
*/
WHERE apply(ISqlOp op, Ifs ifs);
/**
* {@link #apply(Predicate, ISqlOp, Object[])}
*/
@Deprecated
default WHERE apply(boolean condition, ISqlOp op, O... args) {
return this.apply(a -> condition, op, args);
}
WHERE apply(Predicate
© 2015 - 2025 Weber Informatics LLC | Privacy Policy