Class Country

  • All Implemented Interfaces:
    Serializable, Comparable<Country>

    public final class Country
    extends Object
    implements Comparable<Country>, Serializable
    A country or territory.

    This class represents a country or territory that it is useful to identify. Any two letter code may be used, however it is intended to use codes based on ISO-3166-1 alpha-2.

    This class is immutable and thread-safe.

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Country AR
      The country 'AR' - Argentina.
      static Country AT
      The country 'AT' - Austria.
      static Country AU
      The country 'AU' - Australia.
      static Country BE
      The country 'BE' - Belgium.
      static Country BR
      The country 'BR' - Brazil.
      static Country CA
      The country 'CA' - Canada.
      static Country CH
      The country 'CH' - Switzerland.
      static Country CL
      The country 'CL' - Chile.
      static Country CN
      The country 'CN' - China.
      static Country CZ
      The currency 'CZ' - Czech Republic.
      static Country DE
      The country 'DE' - Germany.
      static Country DK
      The country 'DK' - Denmark.
      static Country EG
      The currency 'EG' - Egypt.
      static Country ES
      The currency 'ES' - Spain.
      static Country EU
      The region of 'EU' - Europe (special status in ISO-3166).
      static Country FI
      The currency 'FI' - Finland.
      static Country FR
      The currency 'FR' - France.
      static Country GB
      The country 'GB' - United Kingdom.
      static Country GR
      The country 'GR' - Greece.
      static Country HK
      The currency 'HK' - Hong Kong.
      static Country HU
      The currency 'HU' = Hungary.
      static Country ID
      The country 'ID' - Indonesia.
      static Country IE
      The currency 'IE' - Ireland.
      static Country IL
      The country 'IL' - Israel.
      static Country IN
      The country 'IN' - India.
      static Country IS
      The currency 'IS' - Iceland.
      static Country IT
      The currency 'IT' - Italy.
      static Country JP
      The country 'JP' - Japan.
      static Country KR
      The country 'KR' - South Korea.
      static Country LU
      The currency 'LU' - Luxembourg.
      static Country MX
      The country 'MX' - Mexico.
      static Country MY
      The country 'MY' - Malaysia.
      static Country NL
      The currency 'NL' - Netherlands.
      static Country NO
      The currency 'NO' - Norway.
      static Country NZ
      The country 'NZ' - New Zealand.
      static Country PL
      The currency 'PL' = Poland.
      static Country PT
      The currency 'PT' - Portugal.
      static Country RU
      The currency 'RU' = Russia.
      static Country SA
      The country 'SA' - Saudi Arabia.
      static Country SE
      The currency 'SE' - Sweden.
      static Country SG
      The country 'SG' - Singapore.
      static Country SK
      The currency 'SK' - Slovakia.
      static Country TH
      The country 'TH' - Thailand.
      static Country TR
      The country 'TR' - Turkey.
      static Country US
      The country 'US' - United States.
      static Country ZA
      The country 'ZA' - South Africa.
    • Field Detail

      • EU

        public static final Country EU
        The region of 'EU' - Europe (special status in ISO-3166).
      • AT

        public static final Country AT
        The country 'AT' - Austria.
      • BE

        public static final Country BE
        The country 'BE' - Belgium.
      • CH

        public static final Country CH
        The country 'CH' - Switzerland.
      • CZ

        public static final Country CZ
        The currency 'CZ' - Czech Republic.
      • DE

        public static final Country DE
        The country 'DE' - Germany.
      • DK

        public static final Country DK
        The country 'DK' - Denmark.
      • ES

        public static final Country ES
        The currency 'ES' - Spain.
      • FI

        public static final Country FI
        The currency 'FI' - Finland.
      • FR

        public static final Country FR
        The currency 'FR' - France.
      • GB

        public static final Country GB
        The country 'GB' - United Kingdom.
      • GR

        public static final Country GR
        The country 'GR' - Greece.
      • HU

        public static final Country HU
        The currency 'HU' = Hungary.
      • IE

        public static final Country IE
        The currency 'IE' - Ireland.
      • IS

        public static final Country IS
        The currency 'IS' - Iceland.
      • IT

        public static final Country IT
        The currency 'IT' - Italy.
      • LU

        public static final Country LU
        The currency 'LU' - Luxembourg.
      • NL

        public static final Country NL
        The currency 'NL' - Netherlands.
      • NO

        public static final Country NO
        The currency 'NO' - Norway.
      • PL

        public static final Country PL
        The currency 'PL' = Poland.
      • PT

        public static final Country PT
        The currency 'PT' - Portugal.
      • SE

        public static final Country SE
        The currency 'SE' - Sweden.
      • SK

        public static final Country SK
        The currency 'SK' - Slovakia.
      • TR

        public static final Country TR
        The country 'TR' - Turkey.
      • AR

        public static final Country AR
        The country 'AR' - Argentina.
      • BR

        public static final Country BR
        The country 'BR' - Brazil.
      • CA

        public static final Country CA
        The country 'CA' - Canada.
      • CL

        public static final Country CL
        The country 'CL' - Chile.
      • MX

        public static final Country MX
        The country 'MX' - Mexico.
      • US

        public static final Country US
        The country 'US' - United States.
      • AU

        public static final Country AU
        The country 'AU' - Australia.
      • CN

        public static final Country CN
        The country 'CN' - China.
      • EG

        public static final Country EG
        The currency 'EG' - Egypt.
      • HK

        public static final Country HK
        The currency 'HK' - Hong Kong.
      • ID

        public static final Country ID
        The country 'ID' - Indonesia.
      • IL

        public static final Country IL
        The country 'IL' - Israel.
      • IN

        public static final Country IN
        The country 'IN' - India.
      • JP

        public static final Country JP
        The country 'JP' - Japan.
      • KR

        public static final Country KR
        The country 'KR' - South Korea.
      • MY

        public static final Country MY
        The country 'MY' - Malaysia.
      • NZ

        public static final Country NZ
        The country 'NZ' - New Zealand.
      • RU

        public static final Country RU
        The currency 'RU' = Russia.
      • SA

        public static final Country SA
        The country 'SA' - Saudi Arabia.
      • SG

        public static final Country SG
        The country 'SG' - Singapore.
      • TH

        public static final Country TH
        The country 'TH' - Thailand.
      • ZA

        public static final Country ZA
        The country 'ZA' - South Africa.
    • Method Detail

      • getAvailableCountries

        public static Set<Country> getAvailableCountries()
        Obtains the set of available countries.

        This contains all the countries that have been defined at the point that the method is called.

        Returns:
        an immutable set containing all registered countries
      • of

        public static Country of​(String countryCode)
        Obtains an instance from the specified ISO-3166-1 alpha-2 two letter country code dynamically creating a country if necessary.

        A country is uniquely identified by ISO-3166-1 alpha-2 two letter code. This method creates the country if it is not known.

        Parameters:
        countryCode - the two letter country code, ASCII and upper case
        Returns:
        the singleton instance
        Throws:
        IllegalArgumentException - if the country code is invalid
      • parse

        public static Country parse​(String countryCode)
        Parses a string to obtain a Country.

        The parse is identical to of(String) except that it will convert letters to upper case first.

        Parameters:
        countryCode - the two letter country code, ASCII
        Returns:
        the singleton instance
        Throws:
        IllegalArgumentException - if the country code is invalid
      • of3Char

        public static Country of3Char​(String countryCode)
        Obtains an instance from the specified ISO-3166-1 alpha-3 three letter country code dynamically creating a country if necessary.

        A country is uniquely identified by ISO-3166-1 alpha-3 three letter code. This method creates the country if it is not known.

        Parameters:
        countryCode - the three letter country code, ASCII and upper case
        Returns:
        the singleton instance
        Throws:
        IllegalArgumentException - if the country code is invalid
      • getCode

        public String getCode()
        Gets the two letter ISO code.
        Returns:
        the two letter ISO code
      • getCode3Char

        public String getCode3Char()
        Gets the ISO-3166-1 alpha-3 three letter country code.
        Returns:
        the three letter country code
        Throws:
        IllegalArgumentException - if the country is invalid
      • compareTo

        public int compareTo​(Country other)
        Compares this country to another.

        The comparison sorts alphabetically by the two letter country code.

        Specified by:
        compareTo in interface Comparable<Country>
        Parameters:
        other - the other country
        Returns:
        negative if less, zero if equal, positive if greater
      • equals

        public boolean equals​(Object obj)
        Checks if this country equals another country.

        The comparison checks the two letter country code.

        Overrides:
        equals in class Object
        Parameters:
        obj - the other country, null returns false
        Returns:
        true if equal
      • hashCode

        public int hashCode()
        Returns a suitable hash code for the country.
        Overrides:
        hashCode in class Object
        Returns:
        the hash code
      • toString

        public String toString()
        Returns a string representation of the country, which is the two letter code.
        Overrides:
        toString in class Object
        Returns:
        the two letter country code