Package org.conical.common.bbl.util
Class PropertyMapLoader
java.lang.Object
org.conical.common.bbl.util.PropertyMapLoader
Provides static methods related to reading and validating values read from a resource bundle
- Author:
- rdoherty
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionloadEnumProperties
(String resourceName, Class<T> enumClass) Loads properties from a resource which are defined by the values of an enum.loadProperties
(String resourceBundleName) Finds and reads the file with the given bundle name and loads properties into a key-value map, which it returnsstatic boolean
requiredPropertiesPresent
(Map<String, String> map, String... propKeys) Checks map for a list of required properties (sent in by key name).
-
Constructor Details
-
PropertyMapLoader
public PropertyMapLoader()
-
-
Method Details
-
loadProperties
Finds and reads the file with the given bundle name and loads properties into a key-value map, which it returns- Parameters:
resourceBundleName
- bundle name- Returns:
- map of properties
-
requiredPropertiesPresent
Checks map for a list of required properties (sent in by key name).- Parameters:
map
- map of properties to checkpropKeys
- array of keys to look for- Returns:
- true if all properties listed exist and are non-null, else false
-
loadEnumProperties
public static <T extends Enum<?>> Map<T,String> loadEnumProperties(String resourceName, Class<T> enumClass) Loads properties from a resource which are defined by the values of an enum. If not all properties in the enum can be found, or the resource cannot be read, a runtime exception is thrown.- Parameters:
resourceName
- name of the resourceenumClass
- class of enum defining the property names- Returns:
- map from enum values to property values
-