Package org.bgerp.app.cfg
Class ConfigMap
- Direct Known Subclasses:
Preferences
,SimpleConfigMap
Key - value strings map.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Clears all the parsed configurations fromconfigMap
.entrySet()
abstract String
getBigDecimal
(String key, BigDecimal def) final boolean
getBoolean
(String key) Retrieves by key a boolean value with defaultfalse
.final boolean
getBoolean
(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 Object
Same withgetConfig(Class)
, but with string parameter for calling from scripts.Serializes the data tokey=value
string linesint
int
long
long
Retrieves by key value with support of old keys.Retrieves by key value with support of old keys.boolean
getSokBoolean
(boolean def, boolean validate, String... keys) Retrieves by key value with support of old keys.boolean
getSokBoolean
(boolean def, String... keys) Retrieves by key value with support of old keys.long
getSokLong
(long def, boolean validate, String... keys) Retrieves by key value with support of old keys.long
getSokLong
(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 java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
EMPTY
-
-
Constructor Details
-
ConfigMap
public ConfigMap()
-
-
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:
- Throws:
BGMessageException
-
getSok
Retrieves by key value with support of old keys.- Parameters:
keys
- first key is the actual one, after - olds.- Returns:
-
getInt
-
getInt
-
getLong
-
getLong
-
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:
- Throws:
BGMessageException
-
getSokLong
Retrieves by key value with support of old keys.- Parameters:
def
- default value.keys
- first key is the actual one, after - olds.- Returns:
- Throws:
BGMessageException
-
getBoolean
Retrieves by key a boolean value with defaultfalse
.- Parameters:
key
- the key.- Returns:
- See Also:
-
getBoolean
Retrieves by key a boolean value.- Parameters:
key
- the key.defaultValue
- default value.- Returns:
- 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:
- Throws:
BGMessageException
-
getSokBoolean
Retrieves by key value with support of old keys.- Parameters:
def
- default value.keys
- first key is the actual one, after - olds.- Returns:
- Throws:
BGMessageException
-
getBigDecimal
-
sub
Creates a sub map by a key prefixprefixkey1=value1 prefixkey2=value2 -> map key1=value1 key2=value2
- Parameters:
prefix
- the key prefix for extraction- Returns:
- not
null
config map
-
subSok
Creates a sub map by key prefixesprefixkey1=value1 prefixkey2=value2 -> config map key1=value1 key2=value2
- Parameters:
prefixes
- key prefixes for extraction, the first one is the actual, the rest are deprecated prefixes- Returns:
- not
null
config map
-
subIndexed
Creates a sorted map of maps by a key prefixprefix1.12=2 prefix1.34=4 prefix2.56=2 prefix2.78=4 -> sorted
Map
1={12=2,34=4} 2={56=2,78=4}- Parameters:
prefix
- the key prefix for extraction- Returns:
- not
null
map
-
subSokIndexed
Creates a sorted map of maps by key prefixesprefix1.12=2 prefix1.34=4 prefix2.56=2 prefix2.78=4 -> sorted
Map
1={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
null
map
-
subKeyed
Creates a map of maps by a key prefixprefixa.12=2 prefixa.34=4 prefixb.56=u prefixb.kk=4 -> unsorted map a={12=2,34=4} b={56=u,kk=4}
- Parameters:
prefix
- the key prefix for extraction- Returns:
- not
null
map - See Also:
-
getConfig
Creates if needed and gets pre parsed and cached configuration. Cache key - the class object of the configuration.- Parameters:
clazz
- the configuration class.- Returns:
-
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:
-
removeConfig
Removes config from cache.- Type Parameters:
K
-- Parameters:
clazz
-
-
clearConfigs
protected void clearConfigs()Clears all the parsed configurations fromconfigMap
. -
validateConfig
Creates a configuration for validation purposes only..- Parameters:
clazz
-- Throws:
BGMessageException
-
getDataString
Serializes the data tokey=value
string lines- Returns:
- the string with pairs on lines
-