Class I18nString

java.lang.Object
es.situm.sdk.model.I18nString
All Implemented Interfaces:
android.os.Parcelable, MapperInterface

public final class I18nString extends Object implements android.os.Parcelable, MapperInterface
A string with a different value depending of the language. It's recommended to support a default value defaultValue() (optional) for non supported languages.

ISO 639-2 is used to identify the languages.

See Also:
  • Field Details

    • EMPTY

      public static final I18nString EMPTY
    • ANY_LANGUAGE

      public static final String ANY_LANGUAGE
      Special code, non ISO 693-2, to denote value to use by default.
      See Also:
    • CREATOR

      public static final android.os.Parcelable.Creator<I18nString> CREATOR
  • Constructor Details

    • I18nString

      public I18nString(@NonNull Map<String,String> values)
      Parameters:
      values - non null map, with non null keys and values. Keys should be language's ISO 693-2 codes
  • Method Details

    • get

      @NonNull public String get(@NonNull String language)
      Obtains the string in the provided language. If there is no value for that language, return value for ANY_LANGUAGE
      Parameters:
      language - ISO 639-2 language name representation, or ANY_LANGUAGE. If is null, will check for ANY_LANGUAGE
      Returns:
      String. Empty if there is no value for this language, or if provided language is null or empty.
    • get

      @NonNull public String get(@NonNull Locale locale)
      Obtains the string in the provided Locale's language Wraps get(String), using Locale.getISO3Language() to take language code.
      Parameters:
      locale - its Locale.getISO3Language() stands for the language.
      Returns:
      String. Empty if there is no value for this language.
      Throws:
      IllegalArgumentException - if locale is null
    • defaultValue

      @NonNull public String defaultValue()
    • has

      public boolean has(@NonNull String language)
      Check if the language is supported by this I18nString
      Parameters:
      language - ISO 639-2 language name representation. Not null.
      Returns:
      true if there is some value for this string, false otherwise.
    • toMap

      public Map<String,Object> toMap()
      Description copied from interface: MapperInterface
      Method to transform object into Map<String, Object>
      Specified by:
      toMap in interface MapperInterface
      Returns:
      Map<String, Object> with the information of the object mapped
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • describeContents

      public int describeContents()
      Specified by:
      describeContents in interface android.os.Parcelable
    • writeToParcel

      public void writeToParcel(android.os.Parcel dest, int flags)
      Specified by:
      writeToParcel in interface android.os.Parcelable