Class MapDataMemory
java.lang.Object
me.a8kj.config.template.memory.impl.MapDataMemory
- All Implemented Interfaces:
DataMemory<MemoryDataType>
A specialized implementation of
DataMemory that uses MemoryDataType as its keys.
Internally, it leverages an EnumMap for high-performance mapping, ensuring
efficient storage and retrieval of configuration data categorized by type.- Since:
- 0.1
- Author:
- a8kj7sea
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all data currently held in memory.booleancontains(MemoryDataType key) Checks if the memory contains a specific key.get(MemoryDataType key) Retrieves a raw object from memory by its key.booleangetBoolean(MemoryDataType key, boolean defaultValue) Retrieves a value as a boolean.doublegetDouble(MemoryDataType key, double defaultValue) Retrieves a value as a double.intgetInt(MemoryDataType key, int defaultValue) Retrieves a value as an integer.getKeys(MemoryDataType path, boolean deep) Retrieves a set of keys under a specific path.getString(MemoryDataType key) Retrieves a value as aString.Retrieves a list of strings from the specified key.voidset(MemoryDataType key, Object value) Sets a value in the memory buffer for the specified key.transform(String text, Replacement... replacements) Transforms text by applying placeholders 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
-
Constructor Details
-
MapDataMemory
public MapDataMemory()
-
-
Method Details
-
set
Description copied from interface:DataMemorySets a value in the memory buffer for the specified key.- Specified by:
setin interfaceDataMemory<MemoryDataType>- 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<MemoryDataType>- 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<MemoryDataType>- 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<MemoryDataType>
-
getBoolean
Description copied from interface:DataMemoryRetrieves a value as a boolean.- Specified by:
getBooleanin interfaceDataMemory<MemoryDataType>
-
getDouble
Description copied from interface:DataMemoryRetrieves a value as a double.- Specified by:
getDoublein interfaceDataMemory<MemoryDataType>
-
getStringList
Description copied from interface:DataMemoryRetrieves a list of strings from the specified key.- Specified by:
getStringListin interfaceDataMemory<MemoryDataType>
-
contains
Description copied from interface:DataMemoryChecks if the memory contains a specific key.- Specified by:
containsin interfaceDataMemory<MemoryDataType>
-
getKeys
Description copied from interface:DataMemoryRetrieves a set of keys under a specific path.- Specified by:
getKeysin interfaceDataMemory<MemoryDataType>- 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<MemoryDataType>
-
transform
Transforms text by applying placeholders using the internalReplacementProcessor.- Specified by:
transformin interfaceDataMemory<MemoryDataType>- Parameters:
text- the raw text with placeholders.replacements- the data to be injected.- Returns:
- the processed and formatted string.
-