T
- the type of the implementation.public abstract class ConfigBuilder<T>
extends java.lang.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(java.util.Map<java.lang.String,java.lang.String> configMap,
ConfigBuilder.NamingConvention namingConvention)
Sets the configuration values from the given configuration map for only the available keys.
|
protected static java.lang.Boolean |
getBooleanProperty(java.lang.String name,
java.util.Map<java.lang.String,java.lang.String> map)
Get a boolean property from the map,
null if it cannot be found or it has a wrong type. |
protected static java.lang.Double |
getDoubleProperty(java.lang.String name,
java.util.Map<java.lang.String,java.lang.String> map)
Get a double property from the map,
null if it cannot be found or it has a wrong type. |
protected static java.lang.Integer |
getIntProperty(java.lang.String name,
java.util.Map<java.lang.String,java.lang.String> map)
Get an integer property from the map,
null if it cannot be found or it has a wrong
type. |
protected static java.lang.Long |
getLongProperty(java.lang.String name,
java.util.Map<java.lang.String,java.lang.String> map)
Get a long property from the map,
null if it cannot be found or it has a wrong type. |
protected static java.lang.String |
getStringProperty(java.lang.String name,
java.util.Map<java.lang.String,java.lang.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(java.util.Properties properties)
Sets the configuration values from the given
Properties object. |
T |
readSystemProperties()
Sets the configuration values from system properties.
|
protected abstract T fromConfigMap(java.util.Map<java.lang.String,java.lang.String> configMap, ConfigBuilder.NamingConvention namingConvention)
public T readProperties(java.util.Properties properties)
Properties
object.public T readEnvironmentVariables()
public T readSystemProperties()
@Nullable protected static java.lang.Boolean getBooleanProperty(java.lang.String name, java.util.Map<java.lang.String,java.lang.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 java.lang.Integer getIntProperty(java.lang.String name, java.util.Map<java.lang.String,java.lang.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 java.lang.Long getLongProperty(java.lang.String name, java.util.Map<java.lang.String,java.lang.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 java.lang.String getStringProperty(java.lang.String name, java.util.Map<java.lang.String,java.lang.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 java.lang.Double getDoubleProperty(java.lang.String name, java.util.Map<java.lang.String,java.lang.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.