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

public class MacroObjectMap extends Object
A key-value map associating MacroKey keys with arbitrary Object values, used during macro substitution to store raw objects before formatting.

This class allows both put and putIfAbsent insertion behavior. Null values are not permitted; any null value is automatically replaced with the string literal "NULL".

Primarily intended for internal use within the message pipeline where macro resolution requires intermediate object capture before string conversion. This class is not thread-safe and uses a HashMap internally, as message composition typically occurs on the main server thread within a single execution context.

  • Constructor Details

    • MacroObjectMap

      public MacroObjectMap()
  • Method Details

    • put

      public <T> void put(MacroKey macroKey, T value)
      Inserts a key-value pair into the map. If the value is null, the string "NULL" is used instead.
      Type Parameters:
      T - the type of the value
      Parameters:
      macroKey - the key under which the value should be stored
      value - the value to store, or "NULL" if null
    • putIfAbsent

      public <T> void putIfAbsent(MacroKey macroKey, T value)
      Inserts a key-value pair only if the key is not already present in the map. If the value is null, the string "NULL" is used instead.
      Type Parameters:
      T - the type of the value
      Parameters:
      macroKey - the key to insert
      value - the value to associate, or "NULL" if null
    • get

      public Optional<Object> get(MacroKey macroKey)
      Retrieves the value associated with the specified MacroKey, if present.
      Parameters:
      macroKey - the key whose value to retrieve
      Returns:
      an Optional containing the associated value, or empty if not found