Package com.dua3.utility.i18n
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).
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 Summary
ConstructorsConstructorDescriptionI18NInfo(String bundle, Collection<String> languageTags) Creates an instance of aI18NInforecord class. -
Method Summary
Modifier and TypeMethodDescriptionbundle()Returns the value of thebundlerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thelanguageTagsrecord component.Loads internationalization metadata from a resource file associated with the specified class.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
I18NInfo
Creates an instance of aI18NInforecord class.- Parameters:
bundle- the value for thebundlerecord componentlanguageTags- the value for thelanguageTagsrecord component
-
-
Method Details
-
load
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 anI18NInfoinstance representing the resource bundle name and supported languageTags.- Parameters:
clazz- the class whose associated "i18n.properties" file should be loaded.- Returns:
- an
Optionalcontaining the parsedI18NInfoif the resource file is found and valid; otherwise, an emptyOptional. - Throws:
IOException- if an error occurs while reading the "i18n.properties" file.
-
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). -
bundle
Returns the value of thebundlerecord component.- Returns:
- the value of the
bundlerecord component
-
languageTags
Returns the value of thelanguageTagsrecord component.- Returns:
- the value of the
languageTagsrecord component
-