package nckd.jxccl.hr.hspm.servicehelper;

import kd.bos.dataentity.TypesContainer;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

/**
 * TODO
 *
 * @author W.Y.C
 * @version 1.0
 * @date 2026/1/5 15:22
 */
public class ServiceFactory {

    private static final Map<String, String> SERVICE_MAP = new HashMap<String, String>() {
        {
            this.put("IPersonnelPredictionService", "nckd.jxccl.hr.hspm.mservice.PersonnelPredictionService");
        }
    };

    public static <T> T getService(Class<T> clazz) {
        return (T)getService(clazz.getSimpleName());
    }

    public static Object getService(String serviceName) {
        String className = (String)SERVICE_MAP.get(serviceName);
        if (className == null) {
            throw new RuntimeException(String.format(Locale.ROOT, "%s service not find", serviceName));
        } else {
            return TypesContainer.getOrRegisterSingletonInstance(className);
        }
    }
}