Package org.uberfire.commons.config
Class ConfigProperties
- java.lang.Object
-
- org.uberfire.commons.config.ConfigProperties
-
public class ConfigProperties extends Object
Encapsulates a collection of Java System Properties by name and value. Includes handy methods for providing and identifying application-provided default values and converting from Strings to other common types.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConfigProperties.ConfigProperty
-
Constructor Summary
Constructors Constructor Description ConfigProperties(Map<String,String> configuredValues)Creates a new container of configured values from which specific config properties can be obtained.ConfigProperties(Properties configuredValues)Creates a new container of configured values from which specific config properties can be obtained.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigProperties.ConfigPropertyget(String name, String defaultValue)Returns the ConfigProperty instance corresponding to the configured value of the given property, or the default if no configured value exists.StringgetConfigurationSummary(String heading)Returns a multi-line string containing a list of all the properties that were retrieved from this instance, in the order they were retrieved.
-
-
-
Constructor Detail
-
ConfigProperties
public ConfigProperties(Map<String,String> configuredValues)
Creates a new container of configured values from which specific config properties can be obtained.- Parameters:
configuredValues- The configured values, which may have been hardcoded in a Map, read from a config file, or whatever.
-
ConfigProperties
public ConfigProperties(Properties configuredValues)
Creates a new container of configured values from which specific config properties can be obtained.- Parameters:
configuredValues- The configured values, which may have been read from a properties file, or obtained fromSystem.getProperties(). If the property set contains entries whose key and value are not both Strings, these entries will be ignored.
-
-
Method Detail
-
get
public ConfigProperties.ConfigProperty get(String name, String defaultValue)
Returns the ConfigProperty instance corresponding to the configured value of the given property, or the default if no configured value exists.- Parameters:
name- the property name. Must not be null.defaultValue- the value to use if no configured value exists. May be null.- Returns:
-
getConfigurationSummary
public String getConfigurationSummary(String heading)
Returns a multi-line string containing a list of all the properties that were retrieved from this instance, in the order they were retrieved. Does not list unused values from the map given in the constructor, since these may contain a lot of unrelated information (for example, when using System.getProperties()). This is useful for printing a summary of the configuration in a given subsystem. It also helps users learn about available configuration values.- Parameters:
heading- a line of text to print before listing the configuration values
-
-