package uk.ac.ebi.quickgo.annotation.service.statistics;

import java.util.HashMap;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Provides configuration information for the statistics service
 *
 * Created 14/08/17
 * @author Edd
 */
@Configuration
@ConfigurationProperties(prefix = "annotation.stats")
public class StatisticsServiceConfig {
    private Map<String, Integer> typeLimitsForStandardUsage = new HashMap<>();
    private Map<String, Integer> typeLimitsForDownloadUsage = new HashMap<>();

    public Map<String, Integer> getTypeLimitsForStandardUsage() {
        return typeLimitsForStandardUsage;
    }

    public void setTypeLimitsForStandardUsage(Map<String, Integer> typeLimitsForStandardUsage) {
        this.typeLimitsForStandardUsage = typeLimitsForStandardUsage;
    }

    public Map<String, Integer> getTypeLimitsForDownloadUsage() {
        return typeLimitsForDownloadUsage;
    }

    public void setTypeLimitsForDownloadUsage(Map<String, Integer> typeLimitsForDownloadUsage) {
        this.typeLimitsForDownloadUsage = typeLimitsForDownloadUsage;
    }

    @Bean
    public RequiredStatisticsProvider requiredStatisticsForStandardUsage(
            StatisticsTypeConfigurer statsTypeConfigurerForStandardUsage) {
        return new RequiredStatisticsProvider(statsTypeConfigurerForStandardUsage);
    }

    @Bean
    public RequiredStatisticsProvider requiredStatisticsForDownloadUsage(
            StatisticsTypeConfigurer statsTypeConfigurerForDownloadUsage) {
        return new RequiredStatisticsProvider(statsTypeConfigurerForDownloadUsage);
    }

    @Bean
    public StatisticsTypeConfigurer statsTypeConfigurerForStandardUsage() {
        return new StatisticsTypeConfigurer(typeLimitsForStandardUsage);
    }

    @Bean
    public StatisticsTypeConfigurer statsTypeConfigurerForDownloadUsage() {
        return new StatisticsTypeConfigurer(typeLimitsForDownloadUsage);
    }
}

@@ -1299,758 +1299,105 @@
 der 
-requiredStatisticsForStandardUsage(%0A            StatisticsTypeConfigurer statsTypeConfigurerForStandardUsage) %7B%0A        return new RequiredStatisticsProvider(statsTypeConfigurerForStandardUsage);%0A    %7D%0A%0A    @Bean%0A    public RequiredStatisticsProvider requiredStatisticsForDownloadUsage(%0A            StatisticsTypeConfigurer statsTypeConfigurerForDownloadUsage) %7B%0A        return new RequiredStatisticsProvider(statsTypeConfigurerForDownloadUsage);%0A    %7D%0A%0A    @Bean%0A    public StatisticsTypeConfigurer statsTypeConfigurerForStandardUsage() %7B%0A        return new StatisticsTypeConfigurer(typeLimitsForStandardUsage);%0A    %7D%0A%0A    @Bean%0A    public StatisticsTypeConfigurer statsTypeConfigurerForDownloadUsage() %7B%0A        return new StatisticsTypeConfigurer(
+statisticsProvider() %7B%0A        return new RequiredStatisticsProvider(typeLimitsForStandardUsage, 
 type

Simplify configuration by creating only one instance of StatisticsProvider based on the properties passed to the class.