All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.pyroscope.javaagent.impl.PropertiesConfigurationProvider Maven / Gradle / Ivy

There is a newer version: 0.14.0
Show newest version
package io.pyroscope.javaagent.impl;

import io.pyroscope.javaagent.api.ConfigurationProvider;

import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import java.util.Properties;

public class PropertiesConfigurationProvider implements ConfigurationProvider {
    final Properties properties;

    public PropertiesConfigurationProvider(Properties properties) {
        this.properties = properties;
    }

    public PropertiesConfigurationProvider(InputStream source) throws IOException {
        this.properties = new Properties();
        this.properties.load(source);
    }

    @Override
    public String get(String key) {
        String v = properties.getProperty(key);
        if (v == null) {
            String k2 = key.toLowerCase(Locale.ROOT)
                .replace('_', '.');
            v = properties.getProperty(k2);
        }
        return v;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy