java.lang.Object
com.winterhavenmc.library.messagebuilder.model.message.ValidMessage
All Implemented Interfaces:
Message

public final class ValidMessage extends Object implements Message
A concrete implementation of Message representing a fully constructed, resolvable, and sendable message.

This class encapsulates all components required to render and dispatch a message:

The recipient is also automatically added as a macro object under the key [RECIPIENT}.
See Also:
  • Constructor Details

    • ValidMessage

      public ValidMessage(Recipient.Sendable recipient, RecordKey messageKey, MessagePipeline messagePipeline)
      Class constructor
      Parameters:
      recipient - message recipient
      messageKey - message identifier
      messagePipeline - the message processor that will receive the message when the send method is called
  • Method Details

    • setMacro

      public <K extends Enum<K>, V> Message setMacro(K macro, V value)
      Description copied from interface: Message
      Associates a macro key with a value for later substitution during message rendering.
      Specified by:
      setMacro in interface Message
      Type Parameters:
      K - the enum type of the macro
      V - the value type
      Parameters:
      macro - the macro key to assign
      value - the value to associate with the macro
      Returns:
      the same Message instance, for fluent chaining
    • setMacro

      public <K extends Enum<K>, V> Message setMacro(int quantity, K macro, V value)
      Description copied from interface: Message
      Associates a macro key with a value and explicit quantity, useful for pluralization or contextual substitution that depends on numeric counts.
      Specified by:
      setMacro in interface Message
      Type Parameters:
      K - the enum type of the macro
      V - the value type
      Parameters:
      quantity - the quantity associated with the value
      macro - the macro key
      value - the object to associate
      Returns:
      the same Message instance, for fluent chaining
    • setMacro

      public <K extends Enum<K>> Message setMacro(K macro, Duration duration, ChronoUnit lowerBound)
      Description copied from interface: Message
      Associates a duration with the given macro key, using a defined precision.
      Specified by:
      setMacro in interface Message
      Type Parameters:
      K - the enum type of the macro
      Parameters:
      macro - the macro key
      duration - the Duration to be formatted and resolved
      lowerBound - the ChronoUnit to control formatting granularity
      Returns:
      the same Message instance, for fluent chaining
    • send

      public void send()
      Description copied from interface: Message
      Sends the composed message to the resolved recipient, if valid.

      No-op if the message is invalid or the recipient is missing or unsupported.

      Specified by:
      send in interface Message
    • getMessageKey

      public RecordKey getMessageKey()
      Description copied from interface: Message
      Returns the RecordKey identifying the message template used in composition.
      Specified by:
      getMessageKey in interface Message
      Returns:
      the message key
    • getRecipient

      public Recipient.Sendable getRecipient()
      Description copied from interface: Message
      Returns the Recipient.Sendable to whom the message will be sent.
      Specified by:
      getRecipient in interface Message
      Returns:
      the message recipient
    • getObjectMap

      public MacroObjectMap getObjectMap()
      Description copied from interface: Message
      Returns the MacroObjectMap of macro values bound to this message.
      Specified by:
      getObjectMap in interface Message
      Returns:
      the macro object map