Class ConfigLoader
java.lang.Object
io.nosqlbench.nb.api.config.standard.ConfigLoader
The config loader is meant to be the way that configurations for objects or subsystems are loaded generically.
It supports value which are defined as JSON objects, lists
of JSON objects, or as a fall-back simple parameter maps according to
ParamsParser rules.
Importing configs
Configs can be imported from local files, classpath resources, or URLs. This is supported with the form of
IMPORT{URL}
where URL can be any form mentioned above. This syntax is obtuse and
strange, but the point of this is to use something
that should never occur in the wild, to avoid collisions with actual
configuration content, but which is also clearly doing what it says.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> List<T> load(CharSequence source, Class<? extends T> type) <V> LinkedHashMap<String, V> loadMap(CharSequence source, Class<? extends V> type, Function<V, String> keyer) Load a string into an ordered map of objects, with the key being defined by an extractor function over the objects.
-
Constructor Details
-
ConfigLoader
public ConfigLoader()
-
-
Method Details
-
loadMap
public <V> LinkedHashMap<String,V> loadMap(CharSequence source, Class<? extends V> type, Function<V, String> keyer) Load a string into an ordered map of objects, with the key being defined by an extractor function over the objects. Any duplicate keys are treated as an error. This is a useful method for loading configuration blocks which must be distinctly named.- Type Parameters:
V- The generic parameter for the type field- Parameters:
source- The config datatype- The type of configuration object to be stored in the map valueskeyer- The function that extracts the key- Returns:
- A map of named configuration objects
-
load
-