Package me.a8kj.config.template.memory
Class MemoryEntry<T>
java.lang.Object
me.a8kj.config.template.memory.MemoryEntry<T>
- Type Parameters:
T- the expected type of the value held by this entry.
Represents a predefined entry in the configuration memory.
This class encapsulates both the access key and the expected data type,
providing a type-safe way to fetch values without manual casting or
repeated key strings.
- Since:
- 0.1
- Author:
- a8kj7sea
-
Method Summary
Modifier and TypeMethodDescriptionfetch(DataMemory<String> memory) Fetches the value associated with this entry from the provided memory source.fetchOrDefault(DataMemory<String> memory, T defaultValue) Fetches the value associated with this entry from the provided memory source.key()Returns the configuration key associated with this entry.static <T> MemoryEntry<T> of(String key, MemoryDataType type) Creates a new MemoryEntry instance.type()Returns theMemoryDataTypeof this entry.
-
Method Details
-
of
Creates a new MemoryEntry instance.- Type Parameters:
T- the expected return type.- Parameters:
key- the configuration path/key.type- theMemoryDataTyperepresenting the data's nature.- Returns:
- a new
MemoryEntryinstance. - Since:
- 0.1
-
fetch
Fetches the value associated with this entry from the provided memory source.- Parameters:
memory- theDataMemoryinstance to pull data from.- Returns:
- the value of type T stored at the designated key.
- Since:
- 0.1
-
fetchOrDefault
Fetches the value associated with this entry from the provided memory source. If the value is null, the provided default value will be returned instead.- Parameters:
memory- theDataMemoryinstance to pull data from.defaultValue- the fallback value to return if no value is found.- Returns:
- the stored value or the default value if absent.
- Since:
- 0.3
-
key
Returns the configuration key associated with this entry.- Returns:
- the configuration path/key.
- Since:
- 0.3
-
type
Returns theMemoryDataTypeof this entry.- Returns:
- the memory data type strategy.
- Since:
- 0.3
-