Class LocalizedString
- java.lang.Object
-
- com.sportradar.livedata.sdk.feed.common.entities.LocalizedString
-
- All Implemented Interfaces:
Serializable
public class LocalizedString extends Object implements Serializable
Localized string container where a string is represented by its international value and a collection of translations to other languages.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
LocalizedString()
For SerializableLocalizedString(String internationalValue)
Constructs a new localized string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTranslation(String lang, String translation)
Adds a new translation to the string.boolean
equals(LocalizedString other)
Check for equality.boolean
equals(Object obj)
Check for equality.Set<String>
getAvailableTranslationLanguages()
Available language codes this instance is translated to.String
getInternational()
Returns international string.String
getTranslation(String lang)
Returns translation for the specified language.int
hashCode()
Serves as a hash function for a particular type.String
toString()
Returns international string, if available.
-
-
-
Constructor Detail
-
LocalizedString
public LocalizedString(String internationalValue)
Constructs a new localized string.- Parameters:
internationalValue
- International value
-
LocalizedString
protected LocalizedString()
For Serializable
-
-
Method Detail
-
addTranslation
public void addTranslation(String lang, String translation)
Adds a new translation to the string. Overrides the previous language translations if existed.- Parameters:
lang
- Language codetranslation
- Translation for this language
-
equals
public boolean equals(LocalizedString other)
Check for equality.Note : Compares by the international value only.
- Parameters:
other
- other object- Returns:
- true when equal; false else
-
getAvailableTranslationLanguages
public Set<String> getAvailableTranslationLanguages()
Available language codes this instance is translated to. For instance "de", "en" and so on.Note: Might be empty, then you still have the international name
- Returns:
- all available language codes
-
getInternational
public String getInternational()
Returns international string.- Returns:
- international value
-
getTranslation
public String getTranslation(String lang)
Returns translation for the specified language. Falls back to international string if translation does not exist.- Parameters:
lang
- Language code (null for international string)- Returns:
- Translation for the specified language.
-
hashCode
public int hashCode()
Serves as a hash function for a particular type.
-
equals
public boolean equals(Object obj)
Check for equality.
-
-