Class MurmelConfiguration
java.lang.Object
de.murmelmeister.murmelapi.configuration.MurmelMemory
de.murmelmeister.murmelapi.configuration.MurmelConfiguration
MurmelConfiguration is a configuration management class that extends
MurmelMemory
for handling YAML configuration files. It provides functionality to load and
save configurations in a thread-safe manner.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ReadWriteLockprivate final Lockprivate final org.yaml.snakeyaml.YamlFields inherited from class de.murmelmeister.murmelapi.configuration.MurmelMemory
data -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidflattenData(String prefix, Map<String, Object> map) Recursively flattens a nested map by concatenating keys with a specified prefix and stores the resulting key-value pairs into a flat structure.voidLoads the configuration data from the specified file.static MurmelConfigurationloadConfiguration(File file) Loads the configuration data from the specified file and returns a MurmelConfiguration object.Converts a map with dot-separated keys into a nested map structure.voidSaves the configuration data to the specified file.Methods inherited from class de.murmelmeister.murmelapi.configuration.MurmelMemory
get, get, getBoolean, getBooleanList, getByte, getByteList, getCharacter, getCharacterList, getDouble, getDoubleList, getFloat, getFloatList, getInteger, getIntegerList, getList, getLong, getLongList, getOptional, getShort, getShortList, getString, getStringList, set
-
Field Details
-
yaml
private final org.yaml.snakeyaml.Yaml yaml -
lock
-
writeLock
-
-
Constructor Details
-
MurmelConfiguration
public MurmelConfiguration()
-
-
Method Details
-
load
Loads the configuration data from the specified file.- Parameters:
file- the file to load the data from
-
save
Saves the configuration data to the specified file.- Parameters:
file- the file to save the data to
-
loadConfiguration
Loads the configuration data from the specified file and returns a MurmelConfiguration object.- Parameters:
file- the file to load the data from- Returns:
- a MurmelConfiguration object with the loaded configuration data
-
flattenData
Recursively flattens a nested map by concatenating keys with a specified prefix and stores the resulting key-value pairs into a flat structure.- Parameters:
prefix- the prefix to be used for the keys in the flattened mapmap- the nested map that needs to be flattened
-
nestData
Converts a map with dot-separated keys into a nested map structure.- Parameters:
flatData- a map where keys are dot-separated paths indicating the nesting structure- Returns:
- a nested map constructed based on the dot-separated keys
-