package com.brilliance.isc.common.irtcal.days;

import com.brilliance.isc.common.exception.CommonServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class IrtDaysCalculatorFactory {

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

    public IrtDaysCalculator getCalculator(String calcMethod) {
        IrtDaysCalculator irtDaysCalculator = maps.get(calcMethod);
        if (irtDaysCalculator == null) {
            throw new CommonServiceException("Calculation method " + calcMethod + " unknown");
        }
        return irtDaysCalculator;
    }
}
