Record Class InvalidMessage
java.lang.Object
java.lang.Record
com.winterhavenmc.library.messagebuilder.core.message.InvalidMessage
- Record Components:
reason- the reason this message is considered invalid
- All Implemented Interfaces:
Message
A fallback
Message implementation representing an invalid or unrenderable message.
This is returned by the system when a message cannot be composed — for example,
due to a null recipient or missing configuration.
Calling send() on an InvalidMessage results in a no-op.
The reason for failure is stored in the reason field for debugging
or logging purposes.
This class is typically returned by:
Message.empty()- Internal pipeline safeguards during failed message composition
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionInvalidMessage(String reason) Creates an instance of aInvalidMessagerecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic InvalidMessageempty()Returns a reusableInvalidMessageinstance representing an empty message caused by anullrecipient passed to thecompose()method.final booleanIndicates whether some other object is "equal to" this one.Returns theValidMessageKeyidentifying the message template used in composition.Returns theMacroObjectMapof macro values bound to this message.Returns theRecipient.Sendableto whom the message will be sent.final inthashCode()Returns a hash code value for this object.reason()Returns the value of thereasonrecord component.booleansend()Sends the composed message to the resolved recipient, if valid.setMacro(int quantity, K macro, V value) Associates a macro string 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 string, using a defined precision.setMacro(K macro, V value) Associates a macro string with a value for later substitution during message rendering.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
InvalidMessage
Creates an instance of aInvalidMessagerecord class.- Parameters:
reason- the value for thereasonrecord component
-
-
Method Details
-
empty
Returns a reusableInvalidMessageinstance representing an empty message caused by anullrecipient passed to thecompose()method.- Returns:
- a shared instance of an
InvalidMessagewith a standard failure reason
-
setMacro
Description copied from interface:MessageAssociates a macro string with a value for later substitution during message rendering. -
setMacro
Description copied from interface:MessageAssociates a macro string with a value and explicit quantity, useful for pluralization or contextual substitution that depends on numeric counts. -
setMacro
Description copied from interface:MessageAssociates a duration with the given macro string, using a defined precision.- Specified by:
setMacroin interfaceMessage- Type Parameters:
K- the enum type of the macro- Parameters:
macro- the macro stringduration- theDurationto be formatted and resolvedlowerBound- theChronoUnitto control formatting granularity- Returns:
- the same
Messageinstance, for fluent chaining
-
send
public boolean send()Description copied from interface:MessageSends 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:MessageReturns theValidMessageKeyidentifying the message template used in composition.- Specified by:
getMessageKeyin interfaceMessage- Returns:
- the message string
-
getRecipient
Description copied from interface:MessageReturns theRecipient.Sendableto whom the message will be sent.- Specified by:
getRecipientin interfaceMessage- Returns:
- the message recipient
-
getObjectMap
Description copied from interface:MessageReturns theMacroObjectMapof macro values bound to this message.- Specified by:
getObjectMapin interfaceMessage- Returns:
- the macro object map
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
reason
Returns the value of thereasonrecord component.- Returns:
- the value of the
reasonrecord component
-