Class ValidMessage
java.lang.Object
com.winterhavenmc.library.messagebuilder.model.message.ValidMessage
- All Implemented Interfaces:
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:
- A
recipient
- A
messageKey
identifying the template - A
MessagePipeline
to handle rendering and delivery - A
macro object map
holding values to be substituted into the message
[RECIPIENT
}.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionValidMessage
(Recipient.Sendable recipient, RecordKey messageKey, MessagePipeline messagePipeline) Class constructor -
Method Summary
Modifier and TypeMethodDescriptionReturns theRecordKey
identifying the message template used in composition.Returns theMacroObjectMap
of macro values bound to this message.Returns theRecipient.Sendable
to whom the message will be sent.void
send()
Sends the composed message to the resolved recipient, if valid.setMacro
(int quantity, K macro, V value) Associates a macro key with a value and explicit quantity, useful for pluralization or contextual substitution that depends on numeric counts.setMacro
(K macro, Duration duration, ChronoUnit lowerBound) Associates a duration with the given macro key, using a defined precision.setMacro
(K macro, V value) Associates a macro key with a value for later substitution during message rendering.
-
Constructor Details
-
ValidMessage
public ValidMessage(Recipient.Sendable recipient, RecordKey messageKey, MessagePipeline messagePipeline) Class constructor- Parameters:
recipient
- message recipientmessageKey
- message identifiermessagePipeline
- the message processor that will receive the message when the send method is called
-
-
Method Details
-
setMacro
Description copied from interface:Message
Associates a macro key with a value for later substitution during message rendering. -
setMacro
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. -
setMacro
Description copied from interface:Message
Associates a duration with the given macro key, using a defined precision.- Specified by:
setMacro
in interfaceMessage
- Type Parameters:
K
- the enum type of the macro- Parameters:
macro
- the macro keyduration
- theDuration
to be formatted and resolvedlowerBound
- theChronoUnit
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.
-
getMessageKey
Description copied from interface:Message
Returns theRecordKey
identifying the message template used in composition.- Specified by:
getMessageKey
in interfaceMessage
- Returns:
- the message key
-
getRecipient
Description copied from interface:Message
Returns theRecipient.Sendable
to whom the message will be sent.- Specified by:
getRecipient
in interfaceMessage
- Returns:
- the message recipient
-
getObjectMap
Description copied from interface:Message
Returns theMacroObjectMap
of macro values bound to this message.- Specified by:
getObjectMap
in interfaceMessage
- Returns:
- the macro object map
-