com.easy.query.api4j.sql.SQLWherePredicate Maven / Gradle / Ivy
package com.easy.query.api4j.sql;
import com.easy.query.api4j.select.Queryable;
import com.easy.query.core.enums.SQLLikeEnum;
import com.easy.query.core.enums.SQLPredicateCompare;
import com.easy.query.core.enums.SQLRangeEnum;
import com.easy.query.core.expression.func.ColumnPropertyFunction;
import com.easy.query.core.expression.lambda.Property;
import com.easy.query.core.expression.lambda.SQLExpression1;
import com.easy.query.core.expression.parser.core.available.TableAvailable;
import com.easy.query.core.expression.parser.core.base.WherePredicate;
import com.easy.query.core.util.EasyLambdaUtil;
import java.util.Collection;
/**
* @author xuejiaming
* @FileName: WherePredicate.java
* @Description: 文件说明
* @Date: 2023/2/5 09:09
*/
public interface SQLWherePredicate {
WherePredicate getWherePredicate();
default TableAvailable getTable() {
return getWherePredicate().getTable();
}
/**
* 大于 column > val
*/
default SQLWherePredicate gt(Property column, Object val) {
getWherePredicate().gt(true, EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* 大于 column > val
*
* @param condition 执行条件
* @param column 字段
* @param val 值
* @return children
*/
default SQLWherePredicate gt(boolean condition, Property column, Object val) {
getWherePredicate().gt(condition, EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* 等于 column >= val
*/
default SQLWherePredicate ge(Property column, Object val) {
getWherePredicate().ge(EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* 等于 column >= val
*
* @param condition 执行条件
* @param column 字段
* @param val 值
* @return children
*/
default SQLWherePredicate ge(boolean condition, Property column, Object val) {
getWherePredicate().ge(condition, EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* 等于 column = val
*/
default SQLWherePredicate eq(Property column, Object val) {
getWherePredicate().eq(EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* 等于 column = val
*
* @param condition 执行条件
* @param column 字段
* @param val 值
* @return children
*/
default SQLWherePredicate eq(boolean condition, Property column, Object val) {
getWherePredicate().eq(condition, EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* 不等于 column <> val
*/
default SQLWherePredicate ne(Property column, Object val) {
getWherePredicate().ne(EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* 不等于 column <> val
*
* @param condition 执行条件
* @param column 字段
* @param val 值
* @return children
*/
default SQLWherePredicate ne(boolean condition, Property column, Object val) {
getWherePredicate().ne(condition, EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* 小于等于 column <= val
*/
default SQLWherePredicate le(Property column, Object val) {
getWherePredicate().le(EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* 小于等于 column <= val
*
* @param condition 执行条件
* @param column 字段
* @param val 值
* @return children
*/
default SQLWherePredicate le(boolean condition, Property column, Object val) {
getWherePredicate().le(condition, EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* 小于 column < val
*/
default SQLWherePredicate lt(Property column, Object val) {
getWherePredicate().lt(EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* 小于 column < val
*
* @param condition 执行条件
* @param column 字段
* @param val 值
* @return children
*/
default SQLWherePredicate lt(boolean condition, Property column, Object val) {
getWherePredicate().lt(condition, EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* column like val%
* 列匹配前半部分
*
* @param column
* @param val
* @return
*/
default SQLWherePredicate likeMatchLeft(Property column, Object val) {
getWherePredicate().likeMatchLeft(EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* column like val%
* 列匹配前半部分
*
* @param condition
* @param column
* @param val
* @return
*/
default SQLWherePredicate likeMatchLeft(boolean condition, Property column, Object val) {
getWherePredicate().likeMatchLeft(condition, EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* column like %val
* 列匹配后半部分
*
* @param column
* @param val
* @return
*/
default SQLWherePredicate likeMatchRight(Property column, Object val) {
getWherePredicate().likeMatchRight(EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* column like %val
* 列匹配后半部分
*
* @param condition
* @param column
* @param val
* @return
*/
default SQLWherePredicate likeMatchRight(boolean condition, Property column, Object val) {
getWherePredicate().likeMatchRight(condition, EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* column like %val%
* 列全匹配
*/
default SQLWherePredicate like(Property column, Object val) {
getWherePredicate().like(EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* column like %val%
* 列全匹配
*
* @param condition 执行条件
* @param column 字段
* @param val 值
* @return children
*/
default SQLWherePredicate like(boolean condition, Property column, Object val) {
getWherePredicate().like(condition, EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* column like ?val?
* 列自定义匹配
*
* @param condition
* @param column
* @param val
* @param sqlLike
* @return
*/
default SQLWherePredicate like(boolean condition, Property column, Object val, SQLLikeEnum sqlLike) {
getWherePredicate().like(condition, EasyLambdaUtil.getPropertyName(column), val, sqlLike);
return this;
}
/**
* column not like val%
*
* @param column
* @param val
* @return
*/
default SQLWherePredicate notLikeMatchLeft(Property column, Object val) {
getWherePredicate().notLikeMatchLeft(EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* column not like val%
*
* @param condition
* @param column
* @param val
* @return
*/
default SQLWherePredicate notLikeMatchLeft(boolean condition, Property column, Object val) {
getWherePredicate().notLikeMatchLeft(condition, EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* column not like %val
*
* @param column
* @param val
* @return
*/
default SQLWherePredicate notLikeMatchRight(Property column, Object val) {
getWherePredicate().notLikeMatchRight(EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* column not like %val
*
* @param condition
* @param column
* @param val
* @return
*/
default SQLWherePredicate notLikeMatchRight(boolean condition, Property column, Object val) {
getWherePredicate().notLikeMatchRight(condition, EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* column not like %val%
*/
default SQLWherePredicate notLike(Property column, Object val) {
getWherePredicate().notLike(EasyLambdaUtil.getPropertyName(column), val);
return this;
}
/**
* column not like %val%
*
* @param condition 执行条件
* @param column 字段
* @param val 值
* @return children
*/
default SQLWherePredicate notLike(boolean condition, Property column, Object val) {
getWherePredicate().notLike(condition, EasyLambdaUtil.getPropertyName(column), val);
return this;
}
default SQLWherePredicate notLike(boolean condition, Property column, Object val, SQLLikeEnum sqlLike) {
getWherePredicate().notLike(condition, EasyLambdaUtil.getPropertyName(column), val, sqlLike);
return this;
}
/**
* column is null
*/
default SQLWherePredicate isNull(Property column) {
getWherePredicate().isNull(EasyLambdaUtil.getPropertyName(column));
return this;
}
/**
* column is null
*
* @param condition 执行条件
* @param column 字段
* @return children
*/
default SQLWherePredicate isNull(boolean condition, Property column) {
getWherePredicate().isNull(condition, EasyLambdaUtil.getPropertyName(column));
return this;
}
/**
* column is not null
*/
default SQLWherePredicate isNotNull(Property column) {
getWherePredicate().isNotNull(EasyLambdaUtil.getPropertyName(column));
return this;
}
/**
* column is not null
*
* @param condition 执行条件
* @param column 字段
* @return children
*/
default SQLWherePredicate isNotNull(boolean condition, Property column) {
getWherePredicate().isNotNull(condition, EasyLambdaUtil.getPropertyName(column));
return this;
}
/**
* column in collection
* 集合为空返回False
*/
default SQLWherePredicate in(Property column, Collection> collection) {
getWherePredicate().in(EasyLambdaUtil.getPropertyName(column), collection);
return this;
}
/**
* column in collection
* 集合为空返回False
*/
default SQLWherePredicate in(boolean condition, Property column, Collection> collection) {
getWherePredicate().in(condition, EasyLambdaUtil.getPropertyName(column), collection);
return this;
}
default SQLWherePredicate in(Property column, TProperty[] collection) {
getWherePredicate().in(EasyLambdaUtil.getPropertyName(column), collection);
return this;
}
default SQLWherePredicate in(boolean condition, Property column, TProperty[] collection) {
getWherePredicate().in(condition, EasyLambdaUtil.getPropertyName(column), collection);
return this;
}
default SQLWherePredicate in(Property column, Queryable subQueryable) {
getWherePredicate().in(EasyLambdaUtil.getPropertyName(column), subQueryable);
return this;
}
default SQLWherePredicate in(boolean condition, Property column, Queryable subQueryable) {
getWherePredicate().in(condition, EasyLambdaUtil.getPropertyName(column), subQueryable);
return this;
}
/**
* column not in collection
* 集合为空返回True
*/
default SQLWherePredicate notIn(Property column, Collection> collection) {
getWherePredicate().notIn(EasyLambdaUtil.getPropertyName(column), collection);
return this;
}
/**
* column not in collection
* 集合为空返回True
*/
default SQLWherePredicate notIn(boolean condition, Property column, Collection> collection) {
getWherePredicate().notIn(condition, EasyLambdaUtil.getPropertyName(column), collection);
return this;
}
default SQLWherePredicate notIn(Property column, TProperty[] collection) {
getWherePredicate().notIn(EasyLambdaUtil.getPropertyName(column), collection);
return this;
}
default SQLWherePredicate notIn(boolean condition, Property column, TProperty[] collection) {
getWherePredicate().notIn(condition, EasyLambdaUtil.getPropertyName(column), collection);
return this;
}
default SQLWherePredicate notIn(Property column, Queryable subQueryable) {
getWherePredicate().notIn(EasyLambdaUtil.getPropertyName(column), subQueryable);
return this;
}
default SQLWherePredicate notIn(boolean condition, Property column, Queryable subQueryable) {
getWherePredicate().notIn(condition, EasyLambdaUtil.getPropertyName(column), subQueryable);
return this;
}
default SQLWherePredicate exists(Queryable subQueryable) {
getWherePredicate().exists(subQueryable);
return this;
}
default SQLWherePredicate exists(boolean condition, Queryable subQueryable) {
getWherePredicate().exists(condition, subQueryable);
return this;
}
default SQLWherePredicate notExists(Queryable subQueryable) {
getWherePredicate().notExists(subQueryable);
return this;
}
default SQLWherePredicate notExists(boolean condition, Queryable subQueryable) {
getWherePredicate().notExists(condition, subQueryable);
return this;
}
/**
* 区间 (left..right] = {x | left < x <= right}
* 一般用于范围比如时间,小的时间在前大的时间在后
*
* @param column
* @param conditionLeft
* @param valLeft
* @param conditionRight
* @param valRight
* @return
*/
default SQLWherePredicate rangeOpenClosed(Property column, boolean conditionLeft, Object valLeft, boolean conditionRight, Object valRight) {
return rangeOpenClosed(true, column, conditionLeft, valLeft, conditionRight, valRight);
}
/**
* 区间 (left..right] = {x | left < x <= right}
* 一般用于范围比如时间,小的时间在前大的时间在后
*
* @param condition
* @param column
* @param conditionLeft
* @param valLeft
* @param conditionRight
* @param valRight
* @return
*/
default SQLWherePredicate rangeOpenClosed(boolean condition, Property column, boolean conditionLeft, Object valLeft, boolean conditionRight, Object valRight) {
return range(condition, column, conditionLeft, valLeft, conditionRight, valRight, SQLRangeEnum.OPEN_CLOSED);
}
/**
* 区间 (left..right) = {x | left < x < right}
* 一般用于范围比如时间,小的时间在前大的时间在后
*
* @param column 数据库列
* @param valLeft 区间左侧值
* @param valRight 区间右侧的值
* @return
*/
default SQLWherePredicate rangeOpen(Property column, Object valLeft, Object valRight) {
return rangeOpen(true, column, true, valLeft, true, valRight);
}
/**
* 区间 (left..right) = {x | left < x < right}
* 一般用于范围比如时间,小的时间在前大的时间在后
*
* @param column 数据库列
* @param conditionLeft 是否添加左侧条件
* @param valLeft 区间左侧值
* @param conditionRight 是否添加右侧条件
* @param valRight 区间右侧的值
* @return
*/
default SQLWherePredicate rangeOpen(Property column, boolean conditionLeft, Object valLeft, boolean conditionRight, Object valRight) {
return rangeOpen(true, column, conditionLeft, valLeft, conditionRight, valRight);
}
/**
* 区间 (left..right) = {x | left < x < right}
* 一般用于范围比如时间,小的时间在前大的时间在后
*
* @param condition
* @param column
* @param conditionLeft
* @param valLeft
* @param conditionRight
* @param valRight
* @return
*/
default SQLWherePredicate rangeOpen(boolean condition, Property column, boolean conditionLeft, Object valLeft, boolean conditionRight, Object valRight) {
return range(condition, column, conditionLeft, valLeft, conditionRight, valRight, SQLRangeEnum.OPEN);
}
/**
* [left..right) = {x | left <= x < right}
* 一般用于范围比如时间,小的时间在前大的时间在后
*
* @param column
* @param conditionLeft
* @param valLeft
* @param conditionRight
* @param valRight
* @return
*/
default SQLWherePredicate rangeClosedOpen(Property column, boolean conditionLeft, Object valLeft, boolean conditionRight, Object valRight) {
return rangeClosedOpen(true, column, conditionLeft, valLeft, conditionRight, valRight);
}
/**
* [left..right) = {x | left <= x < right}
* 一般用于范围比如时间,小的时间在前大的时间在后
*
* @param condition
* @param column
* @param conditionLeft
* @param valLeft
* @param conditionRight
* @param valRight
* @return
*/
default SQLWherePredicate rangeClosedOpen(boolean condition, Property column, boolean conditionLeft, Object valLeft, boolean conditionRight, Object valRight) {
return range(condition, column, conditionLeft, valLeft, conditionRight, valRight, SQLRangeEnum.CLOSED_OPEN);
}
/**
* [left..right] = {x | left <= x <= right}
* 一般用于范围比如时间,小的时间在前大的时间在后
*
* @param column
* @param valLeft
* @param valRight
* @return
*/
default SQLWherePredicate rangeClosed(Property column, Object valLeft, Object valRight) {
return rangeClosed(true, column, true, valLeft, true, valRight);
}
/**
* [left..right] = {x | left <= x <= right}
* 一般用于范围比如时间,小的时间在前大的时间在后
*
* @param column
* @param conditionLeft
* @param valLeft
* @param conditionRight
* @param valRight
* @return
*/
default SQLWherePredicate rangeClosed(Property column, boolean conditionLeft, Object valLeft, boolean conditionRight, Object valRight) {
return rangeClosed(true, column, conditionLeft, valLeft, conditionRight, valRight);
}
/**
* [left..right] = {x | left <= x <= right}
* 一般用于范围比如时间,小的时间在前大的时间在后
*
* @param condition
* @param column
* @param conditionLeft
* @param valLeft
* @param conditionRight
* @param valRight
* @return
*/
default SQLWherePredicate rangeClosed(boolean condition, Property column, boolean conditionLeft, Object valLeft, boolean conditionRight, Object valRight) {
return range(condition, column, conditionLeft, valLeft, conditionRight, valRight, SQLRangeEnum.CLOSED);
}
/**
* 自定义范围
* 一般用于范围比如时间,小的时间在前大的时间在后
*
* @param condition
* @param column
* @param conditionLeft
* @param valLeft
* @param conditionRight
* @param valRight
* @param sqlRange
* @return
*/
default SQLWherePredicate range(boolean condition, Property column, boolean conditionLeft, Object valLeft, boolean conditionRight, Object valRight, SQLRangeEnum sqlRange) {
getWherePredicate().range(condition, EasyLambdaUtil.getPropertyName(column), conditionLeft, valLeft, conditionRight, valRight, sqlRange);
return this;
}
default SQLWherePredicate columnFunc(ColumnPropertyFunction columnPropertyFunction, SQLPredicateCompare sqlPredicateCompare, Object val) {
return columnFunc(true, columnPropertyFunction, sqlPredicateCompare, val);
}
default SQLWherePredicate columnFunc(boolean condition, ColumnPropertyFunction columnPropertyFunction, SQLPredicateCompare sqlPredicateCompare, Object val) {
getWherePredicate().columnFunc(condition, columnPropertyFunction, sqlPredicateCompare, val);
return this;
}
default SQLWherePredicate eq(SQLWherePredicate sub, Property column1, Property column2) {
return eq(true, sub, column1, column2);
}
default SQLWherePredicate eq(boolean condition, SQLWherePredicate sub, Property column1, Property column2) {
getWherePredicate().eq(condition, sub.getWherePredicate(), EasyLambdaUtil.getPropertyName(column1), EasyLambdaUtil.getPropertyName(column2));
return this;
}
default SQLWherePredicate then(SQLWherePredicate sub) {
getWherePredicate().then(sub.getWherePredicate());
return sub;
}
default SQLWherePredicate and() {
return and(true);
}
default SQLWherePredicate and(boolean condition) {
getWherePredicate().and(condition);
return this;
}
default SQLWherePredicate and(SQLExpression1> sqlWherePredicateSQLExpression) {
return and(true, sqlWherePredicateSQLExpression);
}
SQLWherePredicate and(boolean condition, SQLExpression1> sqlWherePredicateSQLExpression);
default SQLWherePredicate or() {
return or(true);
}
default SQLWherePredicate or(boolean condition) {
getWherePredicate().or(condition);
return this;
}
default SQLWherePredicate or(SQLExpression1> sqlWherePredicateSQLExpression) {
return or(true, sqlWherePredicateSQLExpression);
}
SQLWherePredicate or(boolean condition, SQLExpression1> sqlWherePredicateSQLExpression);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy