Record Class I18NInfo

java.lang.Object
java.lang.Record
com.dua3.utility.i18n.I18NInfo
Record Components:
bundle - the name of the resource bundle used for localization.
languageTags - collection of contained languageTags (language tags).

public record I18NInfo(String bundle, Collection<String> languageTags) extends Record
Represents internationalization (i18n) metadata for an application, including the resource bundle name and supported languageTags.

This record holds essential information for managing localization via resource bundles in combination with specified languageTags.

  • Constructor Details

    • I18NInfo

      public I18NInfo(String bundle, Collection<String> languageTags)
      Creates an instance of a I18NInfo record class.
      Parameters:
      bundle - the value for the bundle record component
      languageTags - the value for the languageTags record component
  • Method Details

    • load

      public static Optional<I18NInfo> load(Class<?> clazz) throws IOException
      Loads internationalization metadata from a resource file associated with the specified class. The method reads the "i18n.properties" file, extracts the required properties, and constructs an I18NInfo instance representing the resource bundle name and supported languageTags.
      Parameters:
      clazz - the class whose associated "i18n.properties" file should be loaded.
      Returns:
      an Optional containing the parsed I18NInfo if the resource file is found and valid; otherwise, an empty Optional.
      Throws:
      IOException - if an error occurs while reading the "i18n.properties" file.
    • 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.
    • bundle

      public String bundle()
      Returns the value of the bundle record component.
      Returns:
      the value of the bundle record component
    • languageTags

      public Collection<String> languageTags()
      Returns the value of the languageTags record component.
      Returns:
      the value of the languageTags record component