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

cz.jalasoft.util.configuration.provider.JavaPropertyConfigProvider Maven / Gradle / Ivy

The newest version!
package cz.jalasoft.util.configuration.provider;

import cz.jalasoft.util.configuration.source.ConfigSource;

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

/**
 * @author Honza Lastovicka ([email protected])
 * @since 2016-07-27.
 */
public final class JavaPropertyConfigProvider implements ConfigProvider {

    private Properties properties;


    @Override
    public void reload(ConfigSource source) throws IOException {
        properties = new Properties();
        properties.load(source.load());
    }

    @Override
    public String readProperty(String key) {
        if (properties == null) {
            throw new IllegalStateException("Call reload() first before readProperty().");
        }

        return properties.getProperty(key);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy