Enum ConfigUtils
- java.lang.Object
-
- java.lang.Enum<ConfigUtils>
-
- migratedb.core.internal.configuration.ConfigUtils
-
- All Implemented Interfaces:
Serializable,Comparable<ConfigUtils>
public enum ConfigUtils extends Enum<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 voidputArrayIfSet(Map<String,String> config, String key, String[]... values)Puts this property in the config if it has been set in any of these values.static voidputIfSet(Map<String,String> config, String key, Object... values)Puts this property in the config if it has been set in any of these values.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.static ConfigUtilsvalueOf(String name)Returns the enum constant of this type with the specified name.static ConfigUtils[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
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 nameNullPointerException- 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)
Convertspropertiesinto 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 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.
-
-