Package dev.orne.i18n
Interface I18nString
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
I18nFixedString,I18nResourcesString,I18nStringMap
Interface for I18N texts.
- Since:
- 0.1
- Version:
- 1.0, 2021-01
- Author:
- (w) Iker Hernaez
-
Method Summary
Modifier and TypeMethodDescription@NotNull I18nStringMapasMap()Returns this instance represented as anI18nStringMapinstance.static @NotNull I18nFixedStringReturns aI18nFixedStringinstance for the specified text.static I18nResourcesString.BuilderfromResources(@NotNull String defaultMessage) Creates a newI18nResourcesStringbuilder with the specified default text.@NotNull Stringget()Returns the text for the current language.@NotNull StringReturns the text for the specified language, or the default text if no translation is available.@NotNull StringReturns the text for language of the specified locale, or the default text if no translation is available.booleanisEquivalent(I18nString other) Returnstrueif the specifiedI18nStringis equivalent to this instance.static @NotNull I18nStringMapCreates a newI18nStringMapinstance with specified default text and no translations.
-
Method Details
-
fixed
Returns aI18nFixedStringinstance for the specified text.Will return
nulliftextisnull.- Parameters:
text- The fixed text for all languages- Returns:
- A instance with the specified text, or
nulliftextisnull - See Also:
-
mapped
Creates a newI18nStringMapinstance with specified default text and no translations.- Parameters:
defaultText- The default text- Returns:
- The created instance
-
fromResources
Creates a newI18nResourcesStringbuilder with the specified default text.- Parameters:
defaultMessage- The default text- Returns:
- The new
I18nResourcesStringbuilder - See Also:
-
get
Returns the text for the current language.- Returns:
- The text for the current language
-
get
Returns the text for the specified language, or the default text if no translation is available.- Parameters:
language- The language of the requested text- Returns:
- The text for the specified language
-
get
Returns the text for language of the specified locale, or the default text if no translation is available.- Parameters:
locale- The language of the requested text- Returns:
- The text for the specified language
-
isEquivalent
Returnstrueif the specifiedI18nStringis equivalent to this instance.- If
otherisnullreturnsfalse. - If
otheris of the same type callsequals(). - Otherwise checks that the translations for current language of both instances are equal.
- Parameters:
other- The instance to compare against- Returns:
- If both instances are equivalent
- If
-
asMap
Returns this instance represented as anI18nStringMapinstance.- Returns:
- This instance represented as an
I18nStringMapinstance
-