Class I18nString

  • All Implemented Interfaces:
    android.os.Parcelable, MapperInterface

    public final class I18nString
    extends java.lang.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 Detail


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

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

      • I18nString

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

      • get

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

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

        public java.lang.String defaultValue()
      • has

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

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

        public boolean equals​(java.lang.Object o)
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        toString in class java.lang.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