Class MacroStringMap
java.lang.Object
com.winterhavenmc.library.messagebuilder.pipeline.maps.MacroStringMap
A specialized map for storing string macro values keyed by
MacroKey
.
This map is used during the macro resolution phase of the message pipeline to provide string substitution values for placeholders.
All insertions are validated: null and blank strings are considered invalid, and will trigger a validation warning (but are still inserted).
This class is mutable and not thread-safe. It is expected to be used in a single-threaded message construction context.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(MacroKey key) Returnstrue
if this map contains the specified key.static MacroStringMap
empty()
Returns a new, emptyMacroStringMap
.entrySet()
Returns the set of key-value entries in this map.Returns the value associated with the given key, ornull
if not found.boolean
isEmpty()
Returnstrue
if this map is empty.keySet()
Returns the set of keys contained in this map.void
Inserts a key-value pair into the map.void
putAll
(MacroStringMap insertionMap) Inserts all entries from anotherMacroStringMap
into this map.void
putIfAbsent
(MacroKey macroKey, String value) Inserts a key-value pair into the map only if the key is not already present.int
size()
Returns the number of entries in this map.Adds a key-value pair to this map and returns the map itself.
-
Constructor Details
-
MacroStringMap
public MacroStringMap()Constructs an emptyMacroStringMap
.
-
-
Method Details
-
put
Inserts a key-value pair into the map. If the value isnull
or blank, a validation warning is logged.- Parameters:
macroKey
- the macro keyvalue
- the string value to associate
-
putIfAbsent
Inserts a key-value pair into the map only if the key is not already present. If the value isnull
or blank, a validation warning is logged.- Parameters:
macroKey
- the macro keyvalue
- the string value to associate
-
get
Returns the value associated with the given key, ornull
if not found.- Parameters:
key
- the macro key- Returns:
- the associated value, or
null
if not present
-
putAll
Inserts all entries from anotherMacroStringMap
into this map. Existing keys will be overwritten.- Parameters:
insertionMap
- the map whose entries should be copied
-
containsKey
Returnstrue
if this map contains the specified key.- Parameters:
key
- the key to check- Returns:
true
if the key is present
-
entrySet
Returns the set of key-value entries in this map.- Returns:
- an iterable view of the map's entries
-
keySet
Returns the set of keys contained in this map.- Returns:
- a set of macro keys
-
isEmpty
public boolean isEmpty()Returnstrue
if this map is empty.- Returns:
true
if there are no entries
-
size
public int size()Returns the number of entries in this map.- Returns:
- the map size
-
empty
Returns a new, emptyMacroStringMap
.- Returns:
- an empty instance
-
with
Adds a key-value pair to this map and returns the map itself. This method is useful for fluent building patterns.- Parameters:
key
- the macro keyvalue
- the string value to associate- Returns:
- this map, with the new entry included
-