Class ConfigUtils
- java.lang.Object
-
- migratedb.v1.core.internal.configuration.ConfigUtils
-
public final class ConfigUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description ConfigUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Map<String,String>loadConfiguration(Reader reader)Reads the configuration from a Reader.static Map<String,String>propertiesToMap(Properties properties)Convertspropertiesinto a map.static BooleanremoveBoolean(Map<String,String> config, String key)static IntegerremoveInteger(Map<String,String> config, String key)static voidreportUnrecognisedProperties(Map<String,String> config, String prefix)Reports all remaining keys inconfigthat start withprefixas unrecognised by throwing an exception.
-
-
-
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)
Convertspropertiesinto 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 inconfigthat start withprefixas unrecognised by throwing an exception. Does nothing ifconfigis empty or none of its keys start withprefix.- Parameters:
prefix- The expected prefix for MigrateDB configuration parameters.nullif none.
-
-