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
-
Method Summary
Modifier and TypeMethodDescription@Nullable String
code()
Returns the value of thecode
record component.int
@NonNull @NotBlank String
Returns the value of thedefaultMessage
record component.boolean
Indicates whether some other object is "equal to" this one.int
hashCode()
Returns a hash code value for this object.static @NonNull Message
of
(@NonNull io.micronaut.core.beans.BeanProperty<?, ?> beanProperty) static @NonNull Message
of
(@NonNull jakarta.validation.ConstraintViolation<?> violation) static @NonNull Message
static @NonNull Message
static @NonNull Message
static @NonNull Message
final String
toString()
Returns a string representation of this record class.@Nullable Object[]
Returns the value of thevariables
record 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 aMessage
record class.- Parameters:
defaultMessage
- the value for thedefaultMessage
record componentcode
- the value for thecode
record componentvariables
- the value for thevariables
record 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:
compareTo
in 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
Message
instance.
-
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
Message
instance.
-
of
- Parameters:
defaultMessage
- The default message to use if no code is specified or no localized message found- Returns:
- A
Message
instance.
-
of
- Parameters:
type
- Field Typename
- Field name- Returns:
- A
Message
instance.
-
of
@NonNull public static @NonNull Message of(@NonNull @NonNull io.micronaut.core.beans.BeanProperty<?, ?> beanProperty) - Parameters:
beanProperty
- A Bean Property- Returns:
- A
Message
instance.
-
of
@NonNull public static @NonNull Message of(@NonNull @NonNull jakarta.validation.ConstraintViolation<?> violation) - Parameters:
violation
- Constraint Violation- Returns:
- A
Message
instance.
-
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 thedefaultMessage
record component.- Returns:
- the value of the
defaultMessage
record component
-
code
Returns the value of thecode
record component.- Returns:
- the value of the
code
record component
-
variables
Returns the value of thevariables
record component.- Returns:
- the value of the
variables
record component
-