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
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 Summary
Fields -
Constructor Summary
Constructors -
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(K 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(K 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) Applies text transformations using the internalReplacementProcessor.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 map used to store configuration values. Initialized with a standardHashMapfor O(1) average time complexity.
-
-
Constructor Details
-
GenericMapDataMemory
public GenericMapDataMemory()
-
-
Method Details
-
set
Description copied from interface:DataMemorySets a value in the memory buffer for the specified key.- Specified by:
setin interfaceDataMemory<K>- 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<K>- 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<K>- 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<K>
-
getBoolean
Description copied from interface:DataMemoryRetrieves a value as a boolean.- Specified by:
getBooleanin interfaceDataMemory<K>
-
getDouble
Description copied from interface:DataMemoryRetrieves a value as a double.- Specified by:
getDoublein interfaceDataMemory<K>
-
getStringList
Description copied from interface:DataMemoryRetrieves a list of strings from the specified key.- Specified by:
getStringListin interfaceDataMemory<K>
-
contains
Description copied from interface:DataMemoryChecks if the memory contains a specific key.- Specified by:
containsin interfaceDataMemory<K>
-
getKeys
Description copied from interface:DataMemoryRetrieves a set of keys under a specific path.- Specified by:
getKeysin interfaceDataMemory<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:DataMemoryClears all data currently held in memory.- Specified by:
clearin interfaceDataMemory<K>
-
transform
Applies text transformations using the internalReplacementProcessor.- Specified by:
transformin interfaceDataMemory<K>- Parameters:
text- the string to be processed.replacements- the placeholder mappings to apply.- Returns:
- the processed string with all replacements injected.
-