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.
- All Implemented Interfaces:
Comparable<Message>
@Introspected
public record Message(@NonNull @NotBlank String defaultMessage, @Nullable String code)
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.final booleanIndicates whether some other object is "equal to" this one.final 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 Messagefinal StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Message
public Message(@NonNull @NotBlank @NonNull @NotBlank String defaultMessage, @Nullable @Nullable String code) Creates an instance of aMessagerecord class.- Parameters:
defaultMessage- the value for thedefaultMessagerecord componentcode- the value for thecoderecord component
-
-
Method Details
-
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
- 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. -
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). -
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
-