Class Localization

  • All Implemented Interfaces:
    java.io.Serializable

    public class Localization
    extends java.lang.Object
    implements java.io.Serializable
    See Also:
    Serialized Form
    • Constructor Detail

      • Localization

        public Localization​(@Nonnull
                            java.lang.String languageCode,
                            @Nullable
                            java.lang.String countryCode)
      • Localization

        public Localization​(@Nonnull
                            java.lang.String languageCode)
    • Method Detail

      • listFrom

        @Nonnull
        public static java.util.List<Localization> listFrom​(java.lang.String... localizationCodeList)
        Parameters:
        localizationCodeList - a list of localization code, formatted like getLocalizationCode()
        Returns:
        list of Localization objects
        Throws:
        java.lang.IllegalArgumentException - If any of the localizationCodeList is formatted incorrectly
      • fromLocalizationCode

        @Nonnull
        public static java.util.Optional<Localization> fromLocalizationCode​(java.lang.String localizationCode)
        Parameters:
        localizationCode - a localization code, formatted like getLocalizationCode()
        Returns:
        A Localization, if the code was valid.
      • getLanguageCode

        @Nonnull
        public java.lang.String getLanguageCode()
      • getCountryCode

        @Nonnull
        public java.lang.String getCountryCode()
      • fromLocale

        public static Localization fromLocale​(@Nonnull
                                              java.util.Locale locale)
      • getLocalizationCode

        public java.lang.String getLocalizationCode()
        Return a formatted string in the form of: language-Country, or just language if country is null.
        Returns:
        A correctly formatted localizationCode for this localization.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

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

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getLocaleFromThreeLetterCode

        public static java.util.Locale getLocaleFromThreeLetterCode​(@Nonnull
                                                                    java.lang.String code)
                                                             throws ParsingException
        Converts a three letter language code (ISO 639-2/T) to a Locale because limits of Java Locale class.
        Parameters:
        code - a three letter language code
        Returns:
        the Locale corresponding
        Throws:
        ParsingException