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

com.jn.sqlhelper.jsqlparser.expression.BinaryExpressionConverter Maven / Gradle / Ivy

The newest version!
package com.jn.sqlhelper.jsqlparser.expression;

import com.jn.langx.el.expression.operator.BinaryOperator;
import com.jn.langx.util.function.Supplier;
import com.jn.sqlhelper.dialect.expression.SQLExpression;
import net.sf.jsqlparser.expression.BinaryExpression;
import net.sf.jsqlparser.expression.Expression;

public abstract class BinaryExpressionConverter implements ExpressionConverter {

    private Supplier jsqlparserExpressionSupplier;

    public void setJsqlparserExpressionSupplier(Supplier supplier) {
        this.jsqlparserExpressionSupplier = supplier;
    }

    @Override
    public JE toJSqlParserExpression(SE expression) {
        SQLExpression left = (SQLExpression) expression.getLeft();
        SQLExpression right = (SQLExpression) expression.getRight();

        Expression leftExp = ExpressionConverters.toJSqlParserExpression(left);
        Expression rightExp = ExpressionConverters.toJSqlParserExpression(right);

        if (jsqlparserExpressionSupplier != null) {
            JE jsqlparserExpression = jsqlparserExpressionSupplier.get(expression);
            jsqlparserExpression.setLeftExpression(leftExp);
            jsqlparserExpression.setRightExpression(rightExp);
            return jsqlparserExpression;
        } else {
            return buildJSqlParserExpression(expression, leftExp, rightExp);
        }
    }

    protected JE buildJSqlParserExpression(SE expression, Expression leftExp, Expression rightExp) {
        return null;
    }

    @Override
    public SE fromJSqlParserExpression(JE expression) {
        return null;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy