Class EnumDataMemory<E extends Enum<E>>

java.lang.Object
me.a8kj.config.template.memory.impl.EnumDataMemory<E>
Type Parameters:
E - the type of enum to be used as keys.
All Implemented Interfaces:
DataMemory<E>

public abstract class EnumDataMemory<E extends Enum<E>> extends Object implements DataMemory<E>
An abstract implementation of DataMemory that uses an EnumMap as its internal storage. This class provides high-performance data retrieval and storage specifically designed for configurations that use Enum constants as keys.
Since:
0.1
Author:
a8kj7sea
  • Field Details

    • storage

      protected final Map<E extends Enum<E>,Object> storage
      The internal storage map optimized for enum keys.
  • Constructor Details

    • EnumDataMemory

      public EnumDataMemory(Class<E> enumClass)
      Constructs a new EnumDataMemory instance.
      Parameters:
      enumClass - the class of the enum keys to initialize the EnumMap.
  • Method Details

    • set

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

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

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

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

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

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

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

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

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

      public String transform(String text, Replacement... replacements)
      Transforms the input text by processing provided replacements through the configured ReplacementProcessor.
      Specified by:
      transform in interface DataMemory<E extends Enum<E>>
      Parameters:
      text - the string containing placeholders.
      replacements - the variables to be injected into the text.
      Returns:
      the fully processed string.