All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.easy.query.api4j.sql.impl.SQLWhereAggregatePredicateImpl Maven / Gradle / Ivy

There is a newer version: 2.3.3
Show newest version
package com.easy.query.api4j.sql.impl;

import com.easy.query.api4j.sql.SQLWhereAggregatePredicate;
import com.easy.query.core.expression.lambda.SQLExpression1;
import com.easy.query.core.expression.parser.core.base.WhereAggregatePredicate;
import com.easy.query.core.expression.parser.core.base.core.SQLPropertyNative;
import com.easy.query.core.util.EasyObjectUtil;

/**
 * @author xuejiaming
 * @Description: 文件说明
 * @Date: 2023/2/18 22:41
 */
public class SQLWhereAggregatePredicateImpl implements SQLWhereAggregatePredicate {
    private final WhereAggregatePredicate whereAggregatePredicate;

    public SQLWhereAggregatePredicateImpl(WhereAggregatePredicate whereAggregatePredicate) {
        this.whereAggregatePredicate = whereAggregatePredicate;
    }

    @Override
    public WhereAggregatePredicate getWhereAggregatePredicate() {
        return whereAggregatePredicate;
    }

    @Override
    public SQLWhereAggregatePredicate and(boolean condition, SQLExpression1> sqlAggregatePredicateSQLExpression) {
        if (condition) {
            getWhereAggregatePredicate().and(whereAggregatePredicate -> {
                SQLWhereAggregatePredicateImpl sqlWhereAggregatePredicate = new SQLWhereAggregatePredicateImpl<>(whereAggregatePredicate);
                sqlAggregatePredicateSQLExpression.apply(sqlWhereAggregatePredicate);
            });
        }
        return this;
    }

    @Override
    public SQLWhereAggregatePredicate or(boolean condition, SQLExpression1> sqlAggregatePredicateSQLExpression) {
        if (condition) {
            getWhereAggregatePredicate().or(whereAggregatePredicate -> {
                SQLWhereAggregatePredicateImpl sqlWhereAggregatePredicate = new SQLWhereAggregatePredicateImpl<>(whereAggregatePredicate);
                sqlAggregatePredicateSQLExpression.apply(sqlWhereAggregatePredicate);
            });
        }
        return this;
    }

    @Override
    public  SQLPropertyNative getSQLPropertyNative() {
        return EasyObjectUtil.typeCastNullable(whereAggregatePredicate);
    }

    @Override
    public SQLWhereAggregatePredicate castChain() {
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy