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

com.jn.sqlhelper.jsqlparser.instrument.JSqlParserInstrumentation Maven / Gradle / Ivy

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

import com.jn.langx.annotation.Name;
import com.jn.langx.lifecycle.InitializationException;
import com.jn.sqlhelper.dialect.instrument.Instrumentation;
import com.jn.sqlhelper.dialect.instrument.groupby.GroupByTransformer;
import com.jn.sqlhelper.dialect.instrument.orderby.OrderByTransformer;
import com.jn.sqlhelper.dialect.instrument.where.WhereTransformer;
import com.jn.sqlhelper.dialect.sqlparser.SqlParser;
import com.jn.sqlhelper.jsqlparser.sqlparser.JSqlParser;
import com.jn.sqlhelper.jsqlparser.sqlparser.JSqlParserStatementWrapper;
import net.sf.jsqlparser.statement.Statement;

@Name("jsqlparser")
public class JSqlParserInstrumentation implements Instrumentation {
    private boolean enabled = false;
    private boolean inited = false;
    private SqlParser sqlParser;
    private WhereTransformer whereTransformer;
    private OrderByTransformer orderByTransformer;
    private GroupByTransformer groupByTransformer;

    @Override
    public void init() throws InitializationException {
        if (!inited) {
            inited = true;
            this.sqlParser = new JSqlParser();
            whereTransformer = new JSqlParserWhereTransformer();
            whereTransformer.init();
            orderByTransformer = new JSqlParserOrderByTransformer();
            orderByTransformer.init();
            groupByTransformer = new JSqlParserGroupByTransformer();
            groupByTransformer.init();
        }
    }

    @Override
    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    @Override
    public boolean isEnabled() {
        return this.enabled;
    }

    @Override
    public SqlParser getSqlParser() {
        return this.sqlParser;
    }


    @Override
    public WhereTransformer getWhereTransformer() {
        return this.whereTransformer;
    }

    @Override
    public OrderByTransformer getOrderByTransformer() {
        return this.orderByTransformer;
    }

    @Override
    public GroupByTransformer getGroupByTransformer() {
        return groupByTransformer;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy