// Path: modules/utils/src/main/java/com/intuit/autumn/utils/PropertyFactory.java
// public static Properties create(final String propertyResourceName) {
//     return create(propertyResourceName, null);
// }
// 
// Path: modules/utils/src/main/java/com/intuit/autumn/utils/PropertyFactory.java
// public static String getProperty(final String key, final Properties properties) {
//     return getProperty(key, properties, null);
// }


import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.util.concurrent.Service;
import org.slf4j.Logger;
import java.util.Properties;
import java.util.Set;
import static com.google.common.collect.Sets.newHashSet;
import static com.intuit.autumn.utils.PropertyFactory.create;
import static com.intuit.autumn.utils.PropertyFactory.getProperty;
import static org.apache.commons.lang.BooleanUtils.toBoolean;
import static org.slf4j.LoggerFactory.getLogger;
     * Metrics services configuration utility.
     *
     * @return collection of enabled metrics services.
     */

    // todo: ?do better?
    public static Set<Class<? extends Service>> getEnabledMetricsServices() {
        LOGGER.debug("getting enabled metrics services");

        Properties properties = create(PROPERTY_NAME, MetricsModule.class);
        Set<Class<? extends Service>> metricsServices = newHashSet();

        addIfEnabled(properties, metricsServices, "metrics.csv.enabled");
        addIfEnabled(properties, metricsServices, METRICS_GRAPHITE_ENABLED_KEY);
        // note: graphite is needed for hystrix ( don't be alarmed )
        addIfEnabled(properties, metricsServices, "metrics.hystrix.enabled", METRICS_GRAPHITE_ENABLED_KEY);
        addIfEnabled(properties, metricsServices, "metrics.jmx.enabled");

        LOGGER.debug("got enabled metrics services count: {}", metricsServices.size());

        return metricsServices;
    }

    private static void addIfEnabled(final Properties properties, Set<Class<? extends Service>> services,
                                     final String... keys) {
        int keyCounter = 0;
        boolean isEnabled = false;

        for (String key : keys) {
            if (++keyCounter == 1) {
// Path: modules/utils/src/main/java/com/intuit/autumn/utils/PropertyFactory.java
// public static Properties create(final String propertyResourceName) {
//     return create(propertyResourceName, null);
// }
// 
// Path: modules/utils/src/main/java/com/intuit/autumn/utils/PropertyFactory.java
// public static String getProperty(final String key, final Properties properties) {
//     return getProperty(key, properties, null);
// }


// Path: modules/metrics/src/main/java/com/intuit/autumn/metrics/MetricsServices.java
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.util.concurrent.Service;
import org.slf4j.Logger;
import java.util.Properties;
import java.util.Set;
import static com.google.common.collect.Sets.newHashSet;
import static com.intuit.autumn.utils.PropertyFactory.create;
import static com.intuit.autumn.utils.PropertyFactory.getProperty;
import static org.apache.commons.lang.BooleanUtils.toBoolean;
import static org.slf4j.LoggerFactory.getLogger;

     * Metrics services configuration utility.
     *
     * @return collection of enabled metrics services.
     */

    // todo: ?do better?
    public static Set<Class<? extends Service>> getEnabledMetricsServices() {
        LOGGER.debug("getting enabled metrics services");

        Properties properties = create(PROPERTY_NAME, MetricsModule.class);
        Set<Class<? extends Service>> metricsServices = newHashSet();

        addIfEnabled(properties, metricsServices, "metrics.csv.enabled");
        addIfEnabled(properties, metricsServices, METRICS_GRAPHITE_ENABLED_KEY);
        // note: graphite is needed for hystrix ( don't be alarmed )
        addIfEnabled(properties, metricsServices, "metrics.hystrix.enabled", METRICS_GRAPHITE_ENABLED_KEY);
        addIfEnabled(properties, metricsServices, "metrics.jmx.enabled");

        LOGGER.debug("got enabled metrics services count: {}", metricsServices.size());

        return metricsServices;
    }

    private static void addIfEnabled(final Properties properties, Set<Class<? extends Service>> services,
                                     final String... keys) {
        int keyCounter = 0;
        boolean isEnabled = false;

        for (String key : keys) {
            if (++keyCounter == 1) {
                isEnabled = toBoolean(getProperty(key, properties));