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

me.wuwenbin.modules.sql.SQLGen Maven / Gradle / Ivy

There is a newer version: 1.11.0.RELEASE
Show newest version
package me.wuwenbin.modules.sql;


import me.wuwenbin.modules.sql.factory.SQLBeanBuilder;
import me.wuwenbin.modules.sql.factory.SQLTextBuilder;

/**
 * 使用入口方法
 * Created by wuwenbin on 2017/1/12.
 *
 * @author wuwenbin
 * @since 1.1.0
 */
public final class SQLGen {

    private volatile static SQLBeanBuilder sqlBeanBuilder;
    private volatile static SQLTextBuilder sqlTextBuilder;

    private SQLGen() {
    }

    /**
     * 生成 {@link SQLBeanBuilder} 实例
     *
     * @param #targetBeanClass 对应实体类
     * @return {@link SQLBeanBuilder}
     */
    public synchronized static SQLBeanBuilder builder(Class targetBeanClass) {
        if (sqlBeanBuilder == null) {
            synchronized (SQLBeanBuilder.class) {
                if (sqlBeanBuilder == null) {
                    sqlBeanBuilder = new SQLBeanBuilder(targetBeanClass);
                }
            }
        } else if (targetBeanClass != sqlBeanBuilder.getBeanClass()) {
            sqlBeanBuilder = new SQLBeanBuilder(targetBeanClass);
        }
        return sqlBeanBuilder;
    }

    /**
     * 生成 {@link SQLTextBuilder} instance
     *
     * @return {@link SQLTextBuilder}
     */
    public static SQLTextBuilder builder() {
        if (sqlTextBuilder == null) {
            synchronized (SQLTextBuilder.class) {
                if (sqlTextBuilder == null) {
                    sqlTextBuilder = new SQLTextBuilder();
                }
            }
        }
        return sqlTextBuilder;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy