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>
public record Message(@NonNull 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
-
Method Summary
Modifier and TypeMethodDescription@Nullable String
code()
Returns the value of thecode
record component.int
@NonNull String
Returns the value of thedefaultMessage
record component.final boolean
Indicates whether some other object is "equal to" this one.final 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
final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
Message
Creates an instance of aMessage
record class.- Parameters:
defaultMessage
- the value for thedefaultMessage
record componentcode
- the value for thecode
record component
-
-
Method Details
-
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
- 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. -
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 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
-