Class PropertyMapLoader

java.lang.Object
org.conical.common.bbl.util.PropertyMapLoader

public class PropertyMapLoader extends Object
Provides static methods related to reading and validating values read from a resource bundle
Author:
rdoherty
  • Constructor Details

    • PropertyMapLoader

      public PropertyMapLoader()
  • Method Details

    • loadProperties

      public static Map<String,String> loadProperties(String resourceBundleName)
      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

      public static boolean requiredPropertiesPresent(Map<String,String> map, String... propKeys)
      Checks map for a list of required properties (sent in by key name).
      Parameters:
      map - map of properties to check
      propKeys - 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 resource
      enumClass - class of enum defining the property names
      Returns:
      map from enum values to property values