Class Message
java.lang.Object
com.luchersol.core.util.Message
Represents a formatted message with an optional code and arguments.
This class is used for generating messages that can be displayed, logged, or associated with validation errors. Messages can be created from a predefined code (with arguments) or directly from a string.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCode()Returns the message code.static MessageReturns a standard error message with formatting applied (e.g., color and style).Returns the formatted message string.negate()Returns a negated version of this message by appending ".static MessageCreates a newMessagefrom a code and optional arguments.static MessageCreates a newMessagefrom a literal string.
-
Constructor Details
-
Message
Constructs a newMessagewith the given code, message template, and arguments.- Parameters:
code- the message code (can benullif not applicable)message- the message template or literal stringargs- optional arguments to format the message
-
-
Method Details
-
ofCode
-
ofMessage
-
getCode
Returns the message code.- Returns:
- the code associated with this message, or
nullif none
-
getErrorMessage
Returns a standard error message with formatting applied (e.g., color and style).- Returns:
- a
Messageinstance representing a formatted error
-
getMessage
-
negate
Returns a negated version of this message by appending ".__not" to the code and reformatting the message accordingly.- Returns:
- this
Messageinstance after negation
-