Class ConfigMap
- Direct Known Subclasses:
Preferences, SimpleConfigMap
Key - value strings map.
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidClears all the parsed configurations fromconfigMap.entrySet()abstract StringGets a value by key.getBigDecimal(String key, BigDecimal def) Gets aBigDecimalvalue by key.final booleangetBoolean(String key) Retrieves by key a boolean value with defaultfalse.final booleangetBoolean(String key, boolean defaultValue) Retrieves by key a boolean value.final <K extends Config>
KCreates if needed and gets pre parsed and cached configuration.final ObjectSame withgetConfig(Class), but with string parameter for calling from scripts.Serializes the data tokey=valuestring linesintGets an int value by key, default0.intGets an int value by key.longGets a long value by key, default0.longGets a long value by key.Retrieves by key value with support of old keys.Retrieves by key value with support of old keys.booleangetSokBoolean(boolean def, boolean validate, String... keys) Retrieves by key value with support of old keys.booleangetSokBoolean(boolean def, String... keys) Retrieves by key value with support of old keys.longgetSokLong(long def, boolean validate, String... keys) Retrieves by key value with support of old keys.longgetSokLong(long def, String... keys) Retrieves by key value with support of old keys.<K extends Config>
voidremoveConfig(Class<K> clazz) Removes config from cache.Creates a sub map by a key prefixsubIndexed(String prefix) Creates a sorted map of maps by a key prefixCreates a map of maps by a key prefixCreates a sub map by key prefixessubSokIndexed(String... prefixes) Creates a sorted map of maps by key prefixesfinal <K extends Config>
voidvalidateConfig(Class<K> clazz) Creates a configuration for validation purposes only.Methods inherited from class AbstractMap
clear, clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, valuesMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
EMPTY
Empty config map
-
-
Constructor Details
-
ConfigMap
protected ConfigMap()Default constructor
-
-
Method Details
-
get
-
entrySet
-
get
-
getSok
Retrieves by key value with support of old keys.- Parameters:
def- default value.validate- throw an exception on using old keys.keys- first key is the actual one, after - olds.- Returns:
- the value or
def - Throws:
BGMessageException- if a deprecated key is used andvalidateis set
-
getSok
-
getInt
Gets an int value by key.- Parameters:
key- the keydef- default value if absent or not parsable- Returns:
- the value or
def
-
getInt
Gets an int value by key, default0.- Parameters:
key- the key- Returns:
- the value or
0
-
getLong
Gets a long value by key.- Parameters:
key- the keydef- default value if absent or not parsable- Returns:
- the value or
def
-
getLong
Gets a long value by key, default0.- Parameters:
key- the key- Returns:
- the value or
0
-
getSokLong
Retrieves by key value with support of old keys.- Parameters:
def- default value.validate- throw an exception on using old keys.keys- first key is the actual one, after - olds.- Returns:
- the value or
def - Throws:
BGMessageException- if a deprecated key is used andvalidateis set
-
getSokLong
Retrieves by key value with support of old keys.- Parameters:
def- default value.keys- first key is the actual one, after - olds.- Returns:
- the value or
def
-
getBoolean
Retrieves by key a boolean value with defaultfalse.- Parameters:
key- the key.- Returns:
- the value or
false - See Also:
-
getBoolean
Retrieves by key a boolean value.- Parameters:
key- the key.defaultValue- default value.- Returns:
- the value or
defaultValue - See Also:
-
getSokBoolean
public boolean getSokBoolean(boolean def, boolean validate, String... keys) throws BGMessageException Retrieves by key value with support of old keys.- Parameters:
def- default value.validate- throw an exception on using old keys.keys- first key is the actual one, after - olds.- Returns:
- the value or
def - Throws:
BGMessageException- if a deprecated key is used andvalidateis set
-
getSokBoolean
Retrieves by key value with support of old keys.- Parameters:
def- default value.keys- first key is the actual one, after - olds.- Returns:
- the value or
def
-
getBigDecimal
Gets aBigDecimalvalue by key.- Parameters:
key- the keydef- default value if absent or not parsable- Returns:
- the value or
def
-
sub
-
subSok
-
subIndexed
-
subSokIndexed
Creates a sorted map of maps by key prefixesprefix1.12=2 prefix1.34=4 prefix2.56=2 prefix2.78=4 -> sorted
Map1={12=2,34=4} 2={56=2,78=4}- Parameters:
prefixes- key prefixes for extraction, the first one is the actual, the rest are deprecated prefixes- Returns:
- not
nullmap
-
subKeyed
-
getConfig
Creates if needed and gets pre parsed and cached configuration. Cache key - the class object of the configuration.- Type Parameters:
K- configuration type- Parameters:
clazz- the configuration class.- Returns:
- the configuration, or
nullif empty
-
getConfig
Same withgetConfig(Class), but with string parameter for calling from scripts. The method is less recommended asgetConfig(Class), which is checked by compiler.- Parameters:
className- the full class name.- Returns:
- the configuration, or
null
-
removeConfig
-
clearConfigs
protected void clearConfigs()Clears all the parsed configurations fromconfigMap. -
validateConfig
Creates a configuration for validation purposes only.- Type Parameters:
K- configuration type- Parameters:
clazz- configuration class- Throws:
BGMessageException- if the configuration is invalid
-
getDataString
Serializes the data tokey=valuestring lines- Returns:
- the string with pairs on lines
-