Class ConfigUtils


  • public final class ConfigUtils
    extends Object
    • Constructor Detail

      • ConfigUtils

        public ConfigUtils()
    • Method Detail

      • loadConfiguration

        public static Map<String,​String> loadConfiguration​(Reader reader)
        Reads the configuration from a Reader.
        Returns:
        The properties from the configuration file. An empty Map if none.
        Throws:
        MigrateDbException - When the configuration could not be read.
      • propertiesToMap

        public static Map<String,​String> propertiesToMap​(Properties properties)
        Converts properties into a map.
      • removeBoolean

        public static Boolean removeBoolean​(Map<String,​String> config,
                                            String key)
        Parameters:
        config - The config.
        key - The property name.
        Returns:
        The property value as a boolean if it exists, otherwise null.
        Throws:
        MigrateDbException - when the property value is not a valid boolean.
      • removeInteger

        public static Integer removeInteger​(Map<String,​String> config,
                                            String key)
        Parameters:
        config - The config.
        key - The property name.
        Returns:
        The property value as an integer if it exists, otherwise null.
        Throws:
        MigrateDbException - When the property value is not a valid integer.
      • reportUnrecognisedProperties

        public static void reportUnrecognisedProperties​(Map<String,​String> config,
                                                        String prefix)
        Reports all remaining keys in config that start with prefix as unrecognised by throwing an exception. Does nothing if config is empty or none of its keys start with prefix.
        Parameters:
        prefix - The expected prefix for MigrateDB configuration parameters. null if none.