Package dev.orne.i18n
Class I18nFixedString
java.lang.Object
dev.orne.i18n.I18nFixedString
- All Implemented Interfaces:
I18nString
,Serializable
@API(status=STABLE,
since="0.1")
public final class I18nFixedString
extends Object
implements I18nString
Implementation of
I18nString
that doesn't contain translations.
Useful for constant values and I18N texts associated with current thread language (texts provided by users, translations retrieved from DB in lazy mode, etc.).
- Since:
- 0.1
- Version:
- 1.0, 2021-01
- Author:
- (w) Iker Hernaez
- See Also:
-
Method Summary
Modifier and TypeMethodDescription@NotNull I18nStringMap
asMap()
Returns this instance represented as anI18nStringMap
instance.boolean
static I18nFixedString
from
(I18nString source) Creates a new instance with the translation for the current language of the specified sourceI18nString
.static I18nFixedString
Returns an instance for the specified 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.int
hashCode()
boolean
isEquivalent
(I18nString obj) Returnstrue
if the specifiedI18nString
is equivalent to this instance.@NotNull String
toString()
-
Method Details
-
from
Returns an 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
-
from
Creates a new instance with the translation for the current language of the specified sourceI18nString
.Will return
null
ifsource
isnull
.- Parameters:
source
- The source of the I18N text- Returns:
- A instance with the current language translation, or
null
ifsource
isnull
-
get
Returns the text for the current language.- Specified by:
get
in interfaceI18nString
- Returns:
- The text for the current language
-
get
Returns the text for the specified language, or the default text if no translation is available.- Specified by:
get
in interfaceI18nString
- 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.- Specified by:
get
in interfaceI18nString
- Parameters:
locale
- The language of the requested text- Returns:
- The text for the specified language
-
hashCode
public int hashCode() -
equals
-
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.
- Specified by:
isEquivalent
in interfaceI18nString
- Parameters:
obj
- The instance to compare against- Returns:
- If both instances are equivalent
- If
-
asMap
Returns this instance represented as anI18nStringMap
instance.- Specified by:
asMap
in interfaceI18nString
- Returns:
- This instance represented as an
I18nStringMap
instance
-
toString
-