Enum ConfigUtils

    • Method Detail

      • values

        public static ConfigUtils[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (ConfigUtils c : ConfigUtils.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ConfigUtils valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • 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.
      • putIfSet

        public static void putIfSet​(Map<String,​String> config,
                                    String key,
                                    Object... values)
        Puts this property in the config if it has been set in any of these values.
        Parameters:
        config - The config.
        key - The property name.
        values - The values to try. The first non-null value will be set.
      • putArrayIfSet

        public static void putArrayIfSet​(Map<String,​String> config,
                                         String key,
                                         String[]... values)
        Puts this property in the config if it has been set in any of these values.
        Parameters:
        config - The config.
        key - The property name.
        values - The values to try. The first non-null value will be set.
      • 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.