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 I18nStringMap
asMap()
Returns this instance represented as anI18nStringMap
instance.static @NotNull I18nFixedString
Returns aI18nFixedString
instance for the specified text.static I18nResourcesString.Builder
fromResources
(@NotNull String defaultMessage) Creates a newI18nResourcesString
builder with the specified default text.@NotNull String
get()
Returns the text for the current language.@NotNull String
Returns the text for the specified language, or the default text if no translation is available.@NotNull String
Returns the text for language of the specified locale, or the default text if no translation is available.boolean
isEquivalent
(I18nString other) Returnstrue
if the specifiedI18nString
is equivalent to this instance.static @NotNull I18nStringMap
Creates a newI18nStringMap
instance with specified default text and no translations.
-
Method Details
-
fixed
Returns aI18nFixedString
instance for the specified text.Will return
null
iftext
isnull
.- Parameters:
text
- The fixed text for all languages- Returns:
- A instance with the specified text, or
null
iftext
isnull
- See Also:
-
mapped
Creates a newI18nStringMap
instance with specified default text and no translations.- Parameters:
defaultText
- The default text- Returns:
- The created instance
-
fromResources
Creates a newI18nResourcesString
builder with the specified default text.- Parameters:
defaultMessage
- The default text- Returns:
- The new
I18nResourcesString
builder - 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
Returnstrue
if the specifiedI18nString
is equivalent to this instance.- If
other
isnull
returnsfalse
. - If
other
is 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 anI18nStringMap
instance.- Returns:
- This instance represented as an
I18nStringMap
instance
-