package org.diagbot.common.push.naivebayes.factory;

import org.algorithm.core.AlgorithmExecutor;
import org.algorithm.core.cnn.model.RelationExtractionEnsembleModel;
import org.diagbot.common.push.naivebayes.core.AlgorithmNaiveBayesExecutor;

/**
 * @Description:
 * @Author: HUJING
 * @Date: 2019/9/10 15:25
 */
public class AlgorithmNaiveBayesFactory {
    private static AlgorithmNaiveBayesExecutor algorithmNaiveBayesExecutorInstance = null;

    public static AlgorithmExecutor getInstance() {
        try {
            algorithmNaiveBayesExecutorInstance = (AlgorithmNaiveBayesExecutor) create(algorithmNaiveBayesExecutorInstance, AlgorithmNaiveBayesExecutor.class);
        } catch (InstantiationException inst) {
            inst.printStackTrace();
        } catch (IllegalAccessException ille) {
            ille.printStackTrace();
        }
        return algorithmNaiveBayesExecutorInstance;
    }

    private static Object create(Object obj, Class cls) throws InstantiationException, IllegalAccessException {
        if (obj == null) {
            synchronized (cls) {
                obj = cls.newInstance();
            }
        }
        return obj;
    }
}
