package common.utils.model;

import com.jfinal.plugin.activerecord.generator.Generator;
import common.jfinal.AppConfig;

import javax.sql.DataSource;

public class MyGenerator {
    private DataSource dataSource = null;
    private String baseModelPackageName = null;
    private String baseModelOutputDir = null;
    private String modelPackageName = null;
    private String modelOutputDir = null;
    
    private MyGenerator(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    public Generator buildGenerator() {
        return new Generator(dataSource, baseModelPackageName, baseModelOutputDir, modelPackageName, modelOutputDir);
    }
    
    public static MyGenerator create(DataSource dataSource) {
        return new MyGenerator(dataSource);
    }
    
    public MyGenerator setBaseModelPackageName(String baseModelPackageName) {
        this.baseModelPackageName = baseModelPackageName;
        AppConfig.LOGGER.info("BaseModelPackageName: " + baseModelPackageName);
        
        return this;
    }

    public MyGenerator setBaseModelOutputDir(String baseModelOutputDir) {
        this.baseModelOutputDir = baseModelOutputDir;
        AppConfig.LOGGER.info("BaseModelOutputDir: " + baseModelOutputDir);

        return this;
    }

    public MyGenerator setModelPackageName(String modelPackageName) {
        this.modelPackageName = modelPackageName;
        AppConfig.LOGGER.info("ModelPackageName: " + modelPackageName);

        return this;
    }

    public MyGenerator setModelOutputDir(String modelOutputDir) {
        this.modelOutputDir = modelOutputDir;
        AppConfig.LOGGER.info("ModelOutputDir: " + modelOutputDir);

        return this;
    }
}
