java.lang.Object
com.winterhavenmc.library.messagebuilder.pipeline.maps.MacroStringMap

public class MacroStringMap extends Object
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 Details

    • MacroStringMap

      public MacroStringMap()
      Constructs an empty MacroStringMap.
  • Method Details

    • put

      public void put(MacroKey macroKey, String value)
      Inserts a key-value pair into the map. If the value is null or blank, a validation warning is logged.
      Parameters:
      macroKey - the macro key
      value - the string value to associate
    • putIfAbsent

      public void putIfAbsent(MacroKey macroKey, String value)
      Inserts a key-value pair into the map only if the key is not already present. If the value is null or blank, a validation warning is logged.
      Parameters:
      macroKey - the macro key
      value - the string value to associate
    • get

      public String get(MacroKey key)
      Returns the value associated with the given key, or null if not found.
      Parameters:
      key - the macro key
      Returns:
      the associated value, or null if not present
    • putAll

      public void putAll(MacroStringMap insertionMap)
      Inserts all entries from another MacroStringMap into this map. Existing keys will be overwritten.
      Parameters:
      insertionMap - the map whose entries should be copied
    • containsKey

      public boolean containsKey(MacroKey key)
      Returns true if this map contains the specified key.
      Parameters:
      key - the key to check
      Returns:
      true if the key is present
    • entrySet

      public Iterable<? extends Map.Entry<MacroKey,String>> entrySet()
      Returns the set of key-value entries in this map.
      Returns:
      an iterable view of the map's entries
    • keySet

      public Set<MacroKey> keySet()
      Returns the set of keys contained in this map.
      Returns:
      a set of macro keys
    • isEmpty

      public boolean isEmpty()
      Returns true 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

      public static MacroStringMap empty()
      Returns a new, empty MacroStringMap.
      Returns:
      an empty instance
    • with

      public MacroStringMap with(MacroKey key, String value)
      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 key
      value - the string value to associate
      Returns:
      this map, with the new entry included