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 I18nStringMapasMap()Returns this instance represented as anI18nStringMapinstance.booleanstatic I18nFixedStringfrom(I18nString source) Creates a new instance with the translation for the current language of the specified sourceI18nString.static I18nFixedStringReturns an instance for the specified 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.inthashCode()booleanisEquivalent(I18nString obj) Returnstrueif the specifiedI18nStringis equivalent to this instance.@NotNull StringtoString()
-
Method Details
-
from
Returns an instance for the specified text.Will return
nulliftextisnull.- Parameters:
text- The fixed text for all languages- Returns:
- A instance with the specified text, or
nulliftextisnull
-
from
Creates a new instance with the translation for the current language of the specified sourceI18nString.Will return
nullifsourceisnull.- Parameters:
source- The source of the I18N text- Returns:
- A instance with the current language translation, or
nullifsourceisnull
-
get
Returns the text for the current language.- Specified by:
getin 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:
getin 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:
getin interfaceI18nString- Parameters:
locale- The language of the requested text- Returns:
- The text for the specified language
-
hashCode
public int hashCode() -
equals
-
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.
- Specified by:
isEquivalentin interfaceI18nString- Parameters:
obj- The instance to compare against- Returns:
- If both instances are equivalent
- If
-
asMap
Returns this instance represented as anI18nStringMapinstance.- Specified by:
asMapin interfaceI18nString- Returns:
- This instance represented as an
I18nStringMapinstance
-
toString
-