Record Class Message
java.lang.Object
java.lang.Record
io.micronaut.views.fields.messages.Message
- Record Components:
defaultMessage- The default message to use if no code is specified or no localized message found.code- The i18n code which can be used to fetch a localized message.variables- The variables to use resolve message placeholders
- All Implemented Interfaces:
Comparable<Message>
@Introspected
public record Message(@NonNull @NotBlank String defaultMessage, @Nullable String code, @Nullable Object[] variables)
extends Record
implements Comparable<Message>
Message representation. It features an optional
code() to allow localization.- Since:
- 4.1.0
- Author:
- Sergio del Amo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable Stringcode()Returns the value of thecoderecord component.int@NonNull @NotBlank StringReturns the value of thedefaultMessagerecord component.booleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for this object.static @NonNull Messageof(@NonNull io.micronaut.core.beans.BeanProperty<?, ?> beanProperty) static @NonNull Messageof(@NonNull jakarta.validation.ConstraintViolation<?> violation) static @NonNull Messagestatic @NonNull Messagestatic @NonNull Messagestatic @NonNull Messagefinal StringtoString()Returns a string representation of this record class.@Nullable Object[]Returns the value of thevariablesrecord component.
-
Constructor Details
-
Message
-
Message
public Message(@NonNull @NotBlank @NonNull @NotBlank String defaultMessage, @Nullable @Nullable String code, @Nullable @Nullable Object[] variables) Creates an instance of aMessagerecord class.- Parameters:
defaultMessage- the value for thedefaultMessagerecord componentcode- the value for thecoderecord componentvariables- the value for thevariablesrecord component
-
-
Method Details
-
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). -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
compareTo
- Specified by:
compareToin interfaceComparable<Message>
-
of
@NonNull public static @NonNull Message of(@NonNull @NonNull String defaultMessage, @Nullable @Nullable String code) - Parameters:
defaultMessage- The default message to use if no code is specified or no localized message foundcode- The i18n code which can be used to fetch a localized message.- Returns:
- A
Messageinstance.
-
of
@NonNull public static @NonNull Message of(@NonNull @NonNull String defaultMessage, @Nullable @Nullable String code, @Nullable @Nullable Object... variables) - Parameters:
defaultMessage- The default message to use if no code is specified or no localized message foundcode- The i18n code which can be used to fetch a localized message.variables- The variables to use resolve message placeholders- Returns:
- A
Messageinstance.
-
of
- Parameters:
defaultMessage- The default message to use if no code is specified or no localized message found- Returns:
- A
Messageinstance.
-
of
- Parameters:
type- Field Typename- Field name- Returns:
- A
Messageinstance.
-
of
@NonNull public static @NonNull Message of(@NonNull @NonNull io.micronaut.core.beans.BeanProperty<?, ?> beanProperty) - Parameters:
beanProperty- A Bean Property- Returns:
- A
Messageinstance.
-
of
@NonNull public static @NonNull Message of(@NonNull @NonNull jakarta.validation.ConstraintViolation<?> violation) - Parameters:
violation- Constraint Violation- Returns:
- A
Messageinstance.
-
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. -
defaultMessage
Returns the value of thedefaultMessagerecord component.- Returns:
- the value of the
defaultMessagerecord component
-
code
Returns the value of thecoderecord component.- Returns:
- the value of the
coderecord component
-
variables
Returns the value of thevariablesrecord component.- Returns:
- the value of the
variablesrecord component
-