com.easy.query.api4j.sql.impl.SQLWherePredicateImpl Maven / Gradle / Ivy
package com.easy.query.api4j.sql.impl;
import com.easy.query.api4j.sql.SQLWherePredicate;
import com.easy.query.core.context.QueryRuntimeContext;
import com.easy.query.core.expression.lambda.SQLExpression1;
import com.easy.query.core.expression.lambda.SQLExpression2;
import com.easy.query.core.expression.parser.core.base.WherePredicate;
import com.easy.query.core.expression.parser.core.base.core.SQLPropertyNative;
import com.easy.query.core.util.EasyObjectUtil;
/**
* @author xuejiaming
* @Description: 默认的数据库条件比较
* @Date: 2023/2/7 06:58
*/
public class SQLWherePredicateImpl implements SQLWherePredicate {
private final WherePredicate wherePredicate;
public SQLWherePredicateImpl(WherePredicate wherePredicate) {
this.wherePredicate = wherePredicate;
}
@Override
public WherePredicate getWherePredicate() {
return wherePredicate;
}
@Override
public SQLWherePredicate and(boolean condition, SQLExpression1> sqlWherePredicateSQLExpression) {
getWherePredicate().and(condition, predicate -> {
SQLWherePredicate sqlPredicate = new SQLWherePredicateImpl(predicate);
sqlWherePredicateSQLExpression.apply(sqlPredicate);
});
return this;
}
@Override
public SQLWherePredicate or(boolean condition, SQLExpression1> sqlWherePredicateSQLExpression) {
getWherePredicate().or(condition, predicate -> {
SQLWherePredicate sqlPredicate = new SQLWherePredicateImpl(predicate);
sqlWherePredicateSQLExpression.apply(sqlPredicate);
});
return this;
}
@Override
public SQLWherePredicate and(boolean condition, SQLWherePredicate t2SQLWherePredicate, SQLExpression2, SQLWherePredicate> sqlWherePredicateSQLExpression) {
getWherePredicate().and(condition,t2SQLWherePredicate.getWherePredicate(), (predicate1,predicate2) -> {
SQLWherePredicate sqlPredicate1 = new SQLWherePredicateImpl(predicate1);
SQLWherePredicate sqlPredicate2 = new SQLWherePredicateImpl(predicate2);
sqlWherePredicateSQLExpression.apply(sqlPredicate1,sqlPredicate2);
});
return this;
}
@Override
public SQLWherePredicate or(boolean condition, SQLWherePredicate t2SQLWherePredicate, SQLExpression2, SQLWherePredicate> sqlWherePredicateSQLExpression) {
getWherePredicate().or(condition,t2SQLWherePredicate.getWherePredicate(), (predicate1,predicate2) -> {
SQLWherePredicate sqlPredicate1 = new SQLWherePredicateImpl(predicate1);
SQLWherePredicate sqlPredicate2 = new SQLWherePredicateImpl(predicate2);
sqlWherePredicateSQLExpression.apply(sqlPredicate1,sqlPredicate2);
});
return this;
}
@Override
public SQLPropertyNative getSQLPropertyNative() {
return EasyObjectUtil.typeCastNullable(wherePredicate);
}
@Override
public SQLWherePredicate castChain() {
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy