Class MurmelConfiguration

java.lang.Object
de.murmelmeister.murmelapi.configuration.MurmelMemory
de.murmelmeister.murmelapi.configuration.MurmelConfiguration

public class MurmelConfiguration extends MurmelMemory
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 Details

    • yaml

      private final org.yaml.snakeyaml.Yaml yaml
    • lock

      private final ReadWriteLock lock
    • writeLock

      private final Lock writeLock
  • Constructor Details

    • MurmelConfiguration

      public MurmelConfiguration()
  • Method Details

    • load

      public void load(File file)
      Loads the configuration data from the specified file.
      Parameters:
      file - the file to load the data from
    • save

      public void save(File file)
      Saves the configuration data to the specified file.
      Parameters:
      file - the file to save the data to
    • loadConfiguration

      public static MurmelConfiguration loadConfiguration(File file)
      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

      private void flattenData(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.
      Parameters:
      prefix - the prefix to be used for the keys in the flattened map
      map - the nested map that needs to be flattened
    • nestData

      private Map<String,Object> nestData(Map<String,Object> flatData)
      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