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

com.easy.query.gauss.db.func.GaussDBFuncImpl Maven / Gradle / Ivy

The newest version!
package com.easy.query.gauss.db.func;

import com.easy.query.core.enums.SQLLikeEnum;
import com.easy.query.core.expression.lambda.SQLExpression1;
import com.easy.query.core.expression.parser.core.SQLTableOwner;
import com.easy.query.core.func.SQLFuncImpl;
import com.easy.query.core.func.SQLFunction;
import com.easy.query.core.func.column.ColumnExpression;
import com.easy.query.core.func.column.ColumnFuncSelector;
import com.easy.query.core.func.def.DistinctDefaultSQLFunction;
import com.easy.query.core.func.def.enums.DateTimeDurationEnum;
import com.easy.query.core.func.def.enums.DateTimeUnitEnum;
import com.easy.query.core.func.def.enums.MathMethodEnum;
import com.easy.query.core.func.def.enums.TimeUnitEnum;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * create time 2023/10/13 18:16
 * 文件说明
 *
 * @author xuejiaming
 */
public class GaussDBFuncImpl extends SQLFuncImpl {


    @Override
    public SQLFunction nullOrDefault(SQLExpression1 sqlExpression) {
        return new GaussDBNullDefaultSQLFunction(getColumnExpressions(sqlExpression));
    }

    @Override
    public SQLFunction dateTimeFormat(SQLExpression1 sqlExpression, String javaFormat) {
        return new GaussDBDateTimeFormatSQLFunction(getColumnExpressions(sqlExpression), javaFormat);
    }

    @Override
    public SQLFunction dateTimeSQLFormat(SQLTableOwner tableOwner, String property, String format) {
        return new GaussDBDateTimeSQLFormatSQLFunction(getTable(tableOwner), property, format);
    }

    @Override
    public SQLFunction concat(List concatExpressions) {
        return new GaussDBConcatSQLFunction(concatExpressions);
    }
//    @Override
//    public SQLFunction join(String separator, List concatExpressions) {
//        return new PgSQLStringJoinSQLFunction(separator, concatExpressions);
//    }

    @Override
    public SQLFunction now() {
        return GaussDBNowSQLFunction.INSTANCE;
    }

    @Override
    public SQLFunction utcNow() {
        return GaussDBUtcNowSQLFunction.INSTANCE;
    }

    @Override
    public DistinctDefaultSQLFunction sum(SQLExpression1 sqlExpression) {
        return new GaussDBSumSQLFunction(getColumnExpressions(sqlExpression));
    }

    @Override
    public DistinctDefaultSQLFunction count(SQLExpression1 sqlExpression) {
        return new GaussDBCountSQLFunction(getColumnExpressions(sqlExpression));
    }

    @Override
    public DistinctDefaultSQLFunction avg(SQLExpression1 sqlExpression) {
        return new GaussDBAvgSQLFunction(getColumnExpressions(sqlExpression));
    }

    @Override
    public SQLFunction join(SQLExpression1 sqlExpression, boolean distinct) {
        return new GaussDBJoinSQLFunction(getColumnExpressions(sqlExpression),distinct);
    }

    @Override
    public SQLFunction cast(SQLExpression1 sqlExpression, Class targetClazz) {
        return new GaussDBCastSQLFunction(getColumnExpressions(sqlExpression), targetClazz);
    }

    @Override
    public SQLFunction plusDateTime(SQLExpression1 sqlExpression, long duration, TimeUnit timeUnit) {
        return new GaussDBDateTimePlusSQLFunction(getColumnExpressions(sqlExpression), duration, timeUnit);
    }

    @Override
    public SQLFunction plusDateTime2(SQLExpression1 sqlExpression, TimeUnitEnum timeUnit) {
        return new GaussDBDateTime2PlusSQLFunction(getColumnExpressions(sqlExpression), timeUnit);
    }

    @Override
    public SQLFunction plusDateTimeMonths(SQLExpression1 sqlExpression) {
        return new GaussDBDateTimePlusMonthSQLFunction(getColumnExpressions(sqlExpression));
    }

    @Override
    public SQLFunction plusDateTimeYears(SQLExpression1 sqlExpression) {
        return new GaussDBDateTimePlusYearSQLFunction(getColumnExpressions(sqlExpression));
    }

    @Override
    public SQLFunction dateTimeProperty(SQLExpression1 sqlExpression, DateTimeUnitEnum dateTimeUnitEnum) {
        return new GaussDBDateTimePropertySQLFunction(getColumnExpressions(sqlExpression), dateTimeUnitEnum);
    }

    @Override
    public SQLFunction duration(SQLExpression1 sqlExpression, DateTimeDurationEnum durationEnum) {
        return new GaussDBDateTimeDurationSQLFunction(getColumnExpressions(sqlExpression), durationEnum);
    }

    @Override
    public SQLFunction math(SQLExpression1 sqlExpression, MathMethodEnum mathMethodEnum) {
        return new GaussDBMathSQLFunction(getColumnExpressions(sqlExpression), mathMethodEnum);
    }

    @Override
    public SQLFunction like(SQLExpression1 sqlExpression, boolean like, SQLLikeEnum sqlLike) {
        GaussDBLikeSQLFunction likeSQLFunction = new GaussDBLikeSQLFunction(getColumnExpressions(sqlExpression), sqlLike);
        if (!like) {
            return not(x -> x.sqlFunc(likeSQLFunction));
        }
        return likeSQLFunction;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy