package org.algorithm.factory;

import org.algorithm.core.cnn.AlgorithmCNNExecutorPacs;
import org.algorithm.core.cnn.model.RelationExtractionEnsembleModel;

/**
 * @Description:
 * @Author: HUJING
 * @Date: 2019/9/10 15:25
 */
public class RelationExtractionFactory {
    private static RelationExtractionEnsembleModel relationExtractionEnsembleModelInstance = null;

    public static AlgorithmCNNExecutorPacs getInstance() {
        try {
            relationExtractionEnsembleModelInstance = (RelationExtractionEnsembleModel) create(relationExtractionEnsembleModelInstance, RelationExtractionEnsembleModel.class);
        } catch (InstantiationException inst) {
            inst.printStackTrace();
        } catch (IllegalAccessException ille) {
            ille.printStackTrace();
        }
        return relationExtractionEnsembleModelInstance;
    }

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