package cn.feast.coding.generator.factory;

import cn.feast.coding.generator.*;
import cn.feast.coding.tools.Contants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class GeneratorFactory {
    @Autowired
    private SSMGenerator ssmGenerator;
    @Autowired
    private SSHGenerator sshGenerator;
    @Autowired
    private JSPGenerator jspGenerator;
    @Autowired
    private SSMCustomGenerator ssmCustomGenerator;
    @Autowired
    private SSMMavenGenerator ssmMavenGenerator;

    /**
     * 简单工厂模式 ：根据类型选择不同的Generator实现类
     *
     * @param generatorType
     * @return
     */
    public Generator getGenerator(String generatorType) {
        switch (generatorType) {
            case Contants.SSM_FRAME:
                return ssmGenerator;
            case Contants.SSH_FRAME:
                return sshGenerator;
            case Contants.JSP_FRAME:
                return jspGenerator;
            case Contants.SSM_CUSTOM_FRAME:
                return ssmCustomGenerator;
            case Contants.SSM_MAVEN_FRAME:
                return ssmMavenGenerator;
            default:
                return null;
        }
    }
}
