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>
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEnumDataMemory(Class<E> enumClass) Constructs a new EnumDataMemory instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all data currently held in memory.booleanChecks if the memory contains a specific key.Retrieves a raw object from memory by its key.booleangetBoolean(E key, boolean defaultValue) Retrieves a value as a boolean.doubleRetrieves a value as a double.intRetrieves a value as an integer.Retrieves a set of keys under a specific path.Retrieves a value as aString.getStringList(E key) Retrieves a list of strings from the specified key.voidSets a value in the memory buffer for the specified key.transform(String text, Replacement... replacements) Transforms the input text by processing provided replacements through the configuredReplacementProcessor.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.a8kj.config.template.memory.DataMemory
get, getOptional, getProcessor, getString, getStringList
-
Field Details
-
storage
The internal storage map optimized for enum keys.
-
-
Constructor Details
-
EnumDataMemory
Constructs a new EnumDataMemory instance.- Parameters:
enumClass- the class of the enum keys to initialize theEnumMap.
-
-
Method Details
-
set
Description copied from interface:DataMemorySets a value in the memory buffer for the specified key.- Specified by:
setin interfaceDataMemory<E extends Enum<E>>- Parameters:
key- the key where the value should be stored.value- the object to store.
-
get
Description copied from interface:DataMemoryRetrieves a raw object from memory by its key.- Specified by:
getin interfaceDataMemory<E extends Enum<E>>- Parameters:
key- the key to lookup.- Returns:
- the stored object, or
nullif not found.
-
getString
Description copied from interface:DataMemoryRetrieves a value as aString.- Specified by:
getStringin interfaceDataMemory<E extends Enum<E>>- Parameters:
key- the key to lookup.- Returns:
- the string representation of the value.
-
getInt
Description copied from interface:DataMemoryRetrieves a value as an integer.- Specified by:
getIntin interfaceDataMemory<E extends Enum<E>>
-
getBoolean
Description copied from interface:DataMemoryRetrieves a value as a boolean.- Specified by:
getBooleanin interfaceDataMemory<E extends Enum<E>>
-
getDouble
Description copied from interface:DataMemoryRetrieves a value as a double.- Specified by:
getDoublein interfaceDataMemory<E extends Enum<E>>
-
getStringList
Description copied from interface:DataMemoryRetrieves a list of strings from the specified key.- Specified by:
getStringListin interfaceDataMemory<E extends Enum<E>>
-
contains
Description copied from interface:DataMemoryChecks if the memory contains a specific key.- Specified by:
containsin interfaceDataMemory<E extends Enum<E>>
-
getKeys
Description copied from interface:DataMemoryRetrieves a set of keys under a specific path.- Specified by:
getKeysin interfaceDataMemory<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:DataMemoryClears all data currently held in memory.- Specified by:
clearin interfaceDataMemory<E extends Enum<E>>
-
transform
Transforms the input text by processing provided replacements through the configuredReplacementProcessor.- Specified by:
transformin interfaceDataMemory<E extends Enum<E>>- Parameters:
text- the string containing placeholders.replacements- the variables to be injected into the text.- Returns:
- the fully processed string.
-