Class MapPairedDataMemory

java.lang.Object
me.a8kj.config.template.memory.impl.MapPairedDataMemory
All Implemented Interfaces:
DataMemory<String>, PairedDataMemory<String>

public class MapPairedDataMemory extends Object implements PairedDataMemory<String>
A implementation of PairedDataMemory specialized for String keys. This class serves as a concrete storage handler, utilizing a HashMap to manage configuration entries while providing integrated support for text placeholders.
Since:
0.1
Author:
a8kj7sea
  • Constructor Details

    • MapPairedDataMemory

      public MapPairedDataMemory()
  • Method Details

    • set

      public void set(String key, Object value)
      Description copied from interface: DataMemory
      Sets a value in the memory buffer for the specified key.
      Specified by:
      set in interface DataMemory<String>
      Parameters:
      key - the key where the value should be stored.
      value - the object to store.
    • get

      public Object get(String key)
      Description copied from interface: DataMemory
      Retrieves a raw object from memory by its key.
      Specified by:
      get in interface DataMemory<String>
      Parameters:
      key - the key to lookup.
      Returns:
      the stored object, or null if not found.
    • getString

      public String getString(String key)
      Description copied from interface: DataMemory
      Retrieves a value as a String.
      Specified by:
      getString in interface DataMemory<String>
      Parameters:
      key - the key to lookup.
      Returns:
      the string representation of the value.
    • getInt

      public int getInt(String key, int defaultValue)
      Description copied from interface: DataMemory
      Retrieves a value as an integer.
      Specified by:
      getInt in interface DataMemory<String>
    • getBoolean

      public boolean getBoolean(String key, boolean defaultValue)
      Description copied from interface: DataMemory
      Retrieves a value as a boolean.
      Specified by:
      getBoolean in interface DataMemory<String>
    • getDouble

      public double getDouble(String key, double defaultValue)
      Description copied from interface: DataMemory
      Retrieves a value as a double.
      Specified by:
      getDouble in interface DataMemory<String>
    • getStringList

      public List<String> getStringList(String key)
      Description copied from interface: DataMemory
      Retrieves a list of strings from the specified key.
      Specified by:
      getStringList in interface DataMemory<String>
    • contains

      public boolean contains(String key)
      Description copied from interface: DataMemory
      Checks if the memory contains a specific key.
      Specified by:
      contains in interface DataMemory<String>
    • getKeys

      public Set<String> getKeys(String path, boolean deep)
      Description copied from interface: DataMemory
      Retrieves a set of keys under a specific path.
      Specified by:
      getKeys in interface DataMemory<String>
      Parameters:
      path - the parent path.
      deep - whether to include keys from nested sections.
      Returns:
      a set of keys.
    • clear

      public void clear()
      Description copied from interface: DataMemory
      Clears all data currently held in memory.
      Specified by:
      clear in interface DataMemory<String>
    • transform

      public String transform(String text, Replacement... replacements)
      Processes placeholders within the given text using the ReplacementProcessor.
      Specified by:
      transform in interface DataMemory<String>
      Parameters:
      text - the string template containing placeholders.
      replacements - the variable data to inject into the template.
      Returns:
      a formatted string with all replacements applied.