Class GenericMapDataMemory<K>

java.lang.Object
me.a8kj.config.template.memory.impl.GenericMapDataMemory<K>
Type Parameters:
K - the type of keys maintained by this memory storage.
All Implemented Interfaces:
DataMemory<K>
Direct Known Subclasses:
EntityDataMemory, VelocityDataMemory

public class GenericMapDataMemory<K> extends Object implements DataMemory<K>
A flexible, map-based implementation of DataMemory that uses a HashMap for internal storage. This class is ideal for configurations where keys are dynamic or do not follow a specific Enum structure.
Since:
0.1
Author:
a8kj7sea
  • Field Details

    • storage

      protected final Map<K,Object> storage
      The internal map used to store configuration values. Initialized with a standard HashMap for O(1) average time complexity.
  • Constructor Details

    • GenericMapDataMemory

      public GenericMapDataMemory()
  • Method Details

    • set

      public void set(K 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<K>
      Parameters:
      key - the key where the value should be stored.
      value - the object to store.
    • get

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

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

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

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

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

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

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

      public Set<K> getKeys(K path, boolean deep)
      Description copied from interface: DataMemory
      Retrieves a set of keys under a specific path.
      Specified by:
      getKeys in interface DataMemory<K>
      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<K>
    • transform

      public String transform(String text, Replacement... replacements)
      Applies text transformations using the internal ReplacementProcessor.
      Specified by:
      transform in interface DataMemory<K>
      Parameters:
      text - the string to be processed.
      replacements - the placeholder mappings to apply.
      Returns:
      the processed string with all replacements injected.