Class ConfigMap
- All Implemented Interfaces:
Serializable,Cloneable,Map<String,Object>
Configuration entity.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleangetBoolean(String key) Retrieves the value for the given key, interpreted as aBoolean.getBoolean(String key, Boolean valueIfNull) Retrieves the value for the given key, interpreted as aBoolean.Retrieves the value for the given key, interpreted as aDouble.Retrieves the value for the given key, interpreted as aDouble.Retrieves the value for the given key, interpreted as anInteger.Retrieves the value for the given key, interpreted as anInteger.List<com.google.gson.JsonElement>Retrieves a list of values for the given key.The path of the underlying document used to build the configuration map.Retrieves a JSON object for the given key.Retrieves the value for the given key, interpreted as aString.Retrieves the value for the given key, interpreted as aString.Retrieves the value for the given key from environment variables.Get value from system properties.Get value for a given key.<T> TGet value for a given key.inthashCode()final <T> TlogMissingValue(String key, T fallbackValue) Logs an error describing that a value was null (a missing key) and that a fallback value will be used instead.final <T> TlogUnknownValue(String key, T unknownValue, T fallbackValue, T... knownValues) Logs an error that an unknown value was encountered for the given key.voidsetBoolean(String key, Boolean value) Set the value for the given key to the providedBoolean.voidSet the value for the given key to the providedDouble.voidSet the value for the given key to the providedInteger.voidSet the value for the given key to the providedString.Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from class java.util.AbstractMap
toString
-
Constructor Details
-
ConfigMap
-
-
Method Details
-
getValue
Get value for a given key.- Parameters:
key- Key- Returns:
- Value of key
-
getValue
Get value for a given key.- Type Parameters:
T- Class of the Value- Parameters:
key- Keyclazz- Class of the value- Returns:
- Value
-
getString
Retrieves the value for the given key, interpreted as aString.- Parameters:
key- the key of the value to retrieve- Returns:
- the key's value or null if there is no value or if the value cannot be interpreted as a
String
-
getString
Retrieves the value for the given key, interpreted as aString. ReturnsvalueIfNullif the value does not exist, cannot be interpreted as aStringor is null.- Parameters:
key- the key of the value to retrieve if possiblevalueIfNull- the value to return if retrieval was unsuccessful- Returns:
- the key's value or the provided default value
-
getStringFromEnvironment
Retrieves the value for the given key from environment variables.- Parameters:
key- configuration key- Returns:
- the environment variable's value or null if the environment variable has not been set
-
getStringFromSystemProperty
Get value from system properties.- Parameters:
key- configuration key- Returns:
- configuration value
-
setString
Set the value for the given key to the providedString.- Parameters:
key- the key of the value to setvalue- the value to set
-
getInt
Retrieves the value for the given key, interpreted as anInteger.- Parameters:
key- the key of the value to retrieve- Returns:
- the key's value or null if there is no value or if the value cannot be interpreted as an
Integer
-
getInt
Retrieves the value for the given key, interpreted as anInteger. ReturnsvalueIfNullif the value does not exist, cannot be interpreted as anIntegeror is null.- Parameters:
key- the key of the value to retrieve if possiblevalueIfNull- the value to return if retrieval was unsuccessful- Returns:
- the key's value or the provided default value
-
setInt
Set the value for the given key to the providedInteger.- Parameters:
key- the key of the value to setvalue- the value to set
-
getDouble
Retrieves the value for the given key, interpreted as aDouble.- Parameters:
key- the key of the value to retrieve- Returns:
- the key's value or null if there is no value or if the value cannot be interpreted as a
Double
-
getDouble
Retrieves the value for the given key, interpreted as aDouble. ReturnsvalueIfNullif the value does not exist, cannot be interpreted as aDoubleor is null.- Parameters:
key- the key of the value to retrieve if possiblevalueIfNull- the value to return if retrieval was unsuccessful- Returns:
- the key's value or the provided default value
-
setDouble
Set the value for the given key to the providedDouble.- Parameters:
key- the key of the value to setvalue- the value to set
-
getBoolean
Retrieves the value for the given key, interpreted as aBoolean.- Parameters:
key- the key of the value to retrieve- Returns:
- the key's value or null if there is no value or if the value cannot be interpreted as a
Boolean
-
getBoolean
Retrieves the value for the given key, interpreted as aBoolean. ReturnsvalueIfNullif the value does not exist, cannot be interpreted as aBooleanor is null.- Parameters:
key- the key of the value to retrieve if possiblevalueIfNull- the value to return if retrieval was unsuccessful- Returns:
- the key's value or the provided default value
-
setBoolean
Set the value for the given key to the providedBoolean.- Parameters:
key- the key of the value to setvalue- the value to set
-
getList
Retrieves a list of values for the given key.- Parameters:
key- the key of the array to retrieve- Returns:
- the list of JSON elements or an empty list if:
- there is no value
- the value cannot be interpreted as a JSON array
-
getMap
Retrieves a JSON object for the given key.- Parameters:
key- the key of the JSON object to retrieve- Returns:
- a map representing the JSON object or an empty map if:
- there is no value
- the value cannot be interpreted as a JSON object
-
logMissingValue
Logs an error describing that a value was null (a missing key) and that a fallback value will be used instead.- Type Parameters:
T- the fallback value type- Parameters:
key- the missing keyfallbackValue- the value that will be used instead- Returns:
- the fallback value
-
logUnknownValue
@SafeVarargs public final <T> T logUnknownValue(String key, T unknownValue, T fallbackValue, T... knownValues) Logs an error that an unknown value was encountered for the given key. An optional array of known values can be provided to provide more detail.- Type Parameters:
T- the value type- Parameters:
key- the key for which an unknown value was retrievedunknownValue- the unknown valuefallbackValue- the value that will be used insteadknownValues- the array of known values- Returns:
- the fallback value
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getLocation
The path of the underlying document used to build the configuration map.
-