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

play.modules.constretto.store.PlayConfigurationStore Maven / Gradle / Ivy

The newest version!
package play.modules.constretto.store;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.constretto.ConfigurationStore;
import org.constretto.model.TaggedPropertySet;
import play.Play;

import java.util.Collection;
import java.util.Map;
import java.util.Properties;

/**
 * Constretto configuration store thet reads configuration from the currently loaded Play configuration.
 */
public class PlayConfigurationStore implements ConfigurationStore {

    @Override
    public Collection parseConfiguration() {
        TaggedPropertySet taggedPropertySet = new TaggedPropertySet(Play.id, convertPropertiesToStringMap(Play.configuration), getClass());
        return Lists.newArrayList(taggedPropertySet);
    }

    private Map convertPropertiesToStringMap(Properties properties) {
        Map propertiesMap = Maps.newHashMapWithExpectedSize(properties.size());
        for (String propertyName : properties.stringPropertyNames()) {
            propertiesMap.put(propertyName, properties.getProperty(propertyName));
        }
        return propertiesMap;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy