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

import com.brilliance.isc.common.register.saveadddata.SaveDataRegisterFactory;
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 SetDataRegisterFactory {

    public static final String DEFAULT_TYPE = "DEFAULT";

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

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

    public SetDataRegister getSetDataRegister(String type) {
        SetDataRegister setDataRegister = maps.get(type+".setDateRegister");
        if (setDataRegister == null) {
            log.warn("SetDataRegister Type " + type + " unknown, used Default Register");
            setDataRegister = maps.get(DEFAULT_TYPE+".setDateRegister");
        }
        return setDataRegister;
    }
}
