package com.brilliance.isc.common.register.saveadddata;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class SaveDataRegisterFactory {

    public static final String DEFAULT_TYPE = "DEFAULT";

    private static Logger log = LoggerFactory.getLogger(SaveDataRegisterFactory.class);

    @Autowired(required = false)
    private Map<String, SaveDataRegister> maps;

    public SaveDataRegister getSaveDataRegister(String type) {
        SaveDataRegister saveDataRegister = maps.get(type+".saveDateRegister");
        if (saveDataRegister == null) {
            log.warn("SaveDataRegister Type " + type + " unknown, used Default Register");
            saveDataRegister = maps.get(DEFAULT_TYPE+".saveDateRegister");
        }
        return saveDataRegister;
    }
}
