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

org.neogroup.warp.properties.Properties Maven / Gradle / Ivy

There is a newer version: 1.4.3
Show newest version
package org.neogroup.warp.properties;

import java.io.IOException;
import java.io.InputStream;

public abstract class Properties {

    private static final java.util.Properties properties;
    private static final String DEFAULT_PROPERTIES_RESOURCE_NAME = "warp.properties";

    static {
        properties = new java.util.Properties();
        try (InputStream in = Properties.class.getClassLoader().getResourceAsStream(DEFAULT_PROPERTIES_RESOURCE_NAME)) {
            if (in != null) {
                properties.load(in);
            }
        }
        catch (IOException exception) {
            throw new RuntimeException("Error reading properties resource file", exception);
        }
    }

    public static boolean has(String property) {
        return properties.containsKey(property);
    }

    public static void set(String property, Object value) {
        properties.put(property, value);
    }

    public static  R get(String property) {
        return (R)properties.getProperty(property);
    }

    public static  R get(String property, String defaultValue) {
        return (R)properties.getProperty(property, defaultValue);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy