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
    Constructor
    Description
    Message(@NonNull @NotBlank String defaultMessage, @Nullable String code)
    Creates an instance of a Message record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable String
    Returns the value of the code record component.
    int
     
    @NonNull @NotBlank String
    Returns the value of the defaultMessage record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    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
    of(@NonNull String defaultMessage)
     
    static @NonNull Message
    of(@NonNull String defaultMessage, @Nullable String code)
     
    static @NonNull Message
    of(Class<?> type, String name)
     
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Message

      public Message(@NonNull @NotBlank @NonNull @NotBlank String defaultMessage, @Nullable @Nullable String code)
      Creates an instance of a Message record class.
      Parameters:
      defaultMessage - the value for the defaultMessage record component
      code - the value for the code record component
  • Method Details

    • compareTo

      public int compareTo(Message o)
      Specified by:
      compareTo in interface Comparable<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 found
      code - 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)
      Parameters:
      defaultMessage - The default message to use if no code is specified or no localized message found
      Returns:
      A Message instance.
    • of

      @NonNull public static @NonNull Message of(Class<?> type, String name)
      Parameters:
      type - Field Type
      name - 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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • defaultMessage

      @NonNull @NotBlank public @NonNull @NotBlank String defaultMessage()
      Returns the value of the defaultMessage record component.
      Returns:
      the value of the defaultMessage record component
    • code

      @Nullable public @Nullable String code()
      Returns the value of the code record component.
      Returns:
      the value of the code record component