T - the type of the implementation.public abstract class ConfigBuilder<T> extends Object
The type parameter on this class should be set to the type of the implementation of this abstract class. For example, if your subclass is a Foo.Builder, then you would declare it as
Foo.Builder extends ConfigBuilder<Foo.Builder>
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ConfigBuilder.NamingConvention |
| Constructor and Description |
|---|
ConfigBuilder() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract T |
fromConfigMap(Map<String,String> configMap,
ConfigBuilder.NamingConvention namingConvention)
Sets the configuration values from the given configuration map for only the available keys.
|
protected static Boolean |
getBooleanProperty(String name,
Map<String,String> map)
Get a boolean property from the map,
null if it cannot be found or it has a wrong type. |
protected static Double |
getDoubleProperty(String name,
Map<String,String> map)
Get a double property from the map,
null if it cannot be found or it has a wrong type. |
protected static Integer |
getIntProperty(String name,
Map<String,String> map)
Get an integer property from the map,
null if it cannot be found or it has a wrong
type. |
protected static Long |
getLongProperty(String name,
Map<String,String> map)
Get a long property from the map,
null if it cannot be found or it has a wrong type. |
protected static String |
getStringProperty(String name,
Map<String,String> map)
Get a
String property from the map, null if it cannot be found. |
T |
readEnvironmentVariables()
Sets the configuration values from environment variables.
|
T |
readProperties(Properties properties)
Sets the configuration values from the given
Properties object. |
T |
readSystemProperties()
Sets the configuration values from system properties.
|
protected abstract T fromConfigMap(Map<String,String> configMap, ConfigBuilder.NamingConvention namingConvention)
public T readProperties(Properties properties)
Properties object.public T readEnvironmentVariables()
public T readSystemProperties()
@Nullable protected static Boolean getBooleanProperty(String name, Map<String,String> map)
null if it cannot be found or it has a wrong type.name - The property namemap - The map where to look for the propertyBoolean value of the property, null in case of error or if the
property cannot be found.@Nullable protected static Integer getIntProperty(String name, Map<String,String> map)
null if it cannot be found or it has a wrong
type.name - The property namemap - The map where to look for the propertyInteger value of the property, null in case of error or if the
property cannot be found.@Nullable protected static Long getLongProperty(String name, Map<String,String> map)
null if it cannot be found or it has a wrong type.name - The property namemap - The map where to look for the propertyLong value of the property, null in case of error or if the
property cannot be found.@Nullable protected static String getStringProperty(String name, Map<String,String> map)
String property from the map, null if it cannot be found.name - The property namemap - The map where to look for the propertyString value of the property, null if the property cannot be found.@Nullable protected static Double getDoubleProperty(String name, Map<String,String> map)
null if it cannot be found or it has a wrong type.name - The property namemap - The map where to look for the propertyDouble value of the property, null in case of error or if the
property cannot be found.