package com.engine.recruit.factory;

import com.engine.core.impl.Service;
import com.engine.recruit.exception.CustomizeRunTimeException;
import com.engine.recruit.service.ResumeRecognitionService;
import weaver.general.BaseBean;

/**
 * @author:dxfeng
 * @createTime: 2024/01/09
 * @version: 1.0
 */
public class ResumeRecognitionFactory {

    /**
     * 根据类的全路径获取类对象
     *
     * @param className 类全路径
     * @param <T>
     * @return
     */
    public static <T extends Service> Class<T> getClass(String className) {
        Class<?> clazz;
        try {
            clazz = Class.forName(className);
            if (!ResumeRecognitionService.class.isAssignableFrom(clazz)) {
                throw new IllegalArgumentException("该类未实现ResumeRecognitionService");
            }
            return (Class<T>) clazz;
        } catch (ClassNotFoundException e) {
            new BaseBean().writeLog(e);
            throw new CustomizeRunTimeException("简历识别配置出错，未获取到解析实现类[" + className + "]");
        }


    }
}
