All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.thematchbox.common.Country Maven / Gradle / Ivy

Go to download

This project contains some common utilities used in different projects from theMatchBox.

There is a newer version: 2.0.2
Show newest version
package com.thematchbox.common;

/* Copyright 2015 theMatchBox

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/


@SuppressWarnings("UnusedDeclaration")
public enum Country {
    UNDEFINED(null, null, "Undefined"),
    ALA("AX", "248", "AALAND ISLANDS                                 "),
    AFG("AF", "004", "AFGHANISTAN                                    "),
    ALB("AL", "008", "ALBANIA                                        "),
    DZA("DZ", "012", "ALGERIA                                        "),
    ASM("AS", "016", "AMERICAN SAMOA                                 "),
    AND("AD", "020", "ANDORRA                                        "),
    AGO("AO", "024", "ANGOLA                                         "),
    AIA("AI", "660", "ANGUILLA                                       "),
    ATA("AQ", "010", "ANTARCTICA                                     "),
    ATG("AG", "028", "ANTIGUA AND BARBUDA                            "),
    ARG("AR", "032", "ARGENTINA                                      "),
    ARM("AM", "051", "ARMENIA                                        "),
    ABW("AW", "533", "ARUBA                                          "),
    AUS("AU", "036", "AUSTRALIA                                      "),
    AUT("AT", "040", "AUSTRIA                                        "),
    AZE("AZ", "031", "AZERBAIJAN                                     "),
    BHS("BS", "044", "BAHAMAS                                        "),
    BHR("BH", "048", "BAHRAIN                                        "),
    BGD("BD", "050", "BANGLADESH                                     "),
    BRB("BB", "052", "BARBADOS                                       "),
    BLR("BY", "112", "BELARUS                                        "),
    BEL("BE", "056", "BELGIUM                                        "),
    BLZ("BZ", "084", "BELIZE                                         "),
    BEN("BJ", "204", "BENIN                                          "),
    BMU("BM", "060", "BERMUDA                                        "),
    BTN("BT", "064", "BHUTAN                                         "),
    BOL("BO", "068", "BOLIVIA                                        "),
    BIH("BA", "070", "BOSNIA AND HERZEGOWINA                         "),
    BWA("BW", "072", "BOTSWANA                                       "),
    BVT("BV", "074", "BOUVET ISLAND                                  "),
    BRA("BR", "076", "BRAZIL                                         "),
    IOT("IO", "086", "BRITISH INDIAN OCEAN TERRITORY                 "),
    BRN("BN", "096", "BRUNEI DARUSSALAM                              "),
    BGR("BG", "100", "BULGARIA                                       "),
    BFA("BF", "854", "BURKINA FASO                                   "),
    BDI("BI", "108", "BURUNDI                                        "),
    KHM("KH", "116", "CAMBODIA                                       "),
    CMR("CM", "120", "CAMEROON                                       "),
    CAN("CA", "124", "CANADA                                         "),
    CPV("CV", "132", "CAPE VERDE                                     "),
    CYM("KY", "136", "CAYMAN ISLANDS                                 "),
    CAF("CF", "140", "CENTRAL AFRICAN REPUBLIC                       "),
    TCD("TD", "148", "CHAD                                           "),
    CHL("CL", "152", "CHILE                                          "),
    CHN("CN", "156", "CHINA                                          "),
    CXR("CX", "162", "CHRISTMAS ISLAND                               "),
    CCK("CC", "166", "COCOS (KEELING) ISLANDS                        "),
    COL("CO", "170", "COLOMBIA                                       "),
    COM("KM", "174", "COMOROS                                        "),
    COD("CD", "180", "CONGO, Democratic Republic of (was Zaire)      "),
    COG("CG", "178", "CONGO, Republic of                             "),
    COK("CK", "184", "COOK ISLANDS                                   "),
    CRI("CR", "188", "COSTA RICA                                     "),
    CIV("CI", "384", "COTE D'IVOIRE                                  "),
    HRV("HR", "191", "CROATIA (local name: Hrvatska)                 "),
    CUB("CU", "192", "CUBA                                           "),
    CYP("CY", "196", "CYPRUS                                         "),
    CZE("CZ", "203", "CZECH REPUBLIC                                 "),
    DNK("DK", "208", "DENMARK                                        "),
    DJI("DJ", "262", "DJIBOUTI                                       "),
    DMA("DM", "212", "DOMINICA                                       "),
    DOM("DO", "214", "DOMINICAN REPUBLIC                             "),
    ECU("EC", "218", "ECUADOR                                        "),
    EGY("EG", "818", "EGYPT                                          "),
    SLV("SV", "222", "EL SALVADOR                                    "),
    GNQ("GQ", "226", "EQUATORIAL GUINEA                              "),
    ERI("ER", "232", "ERITREA                                        "),
    EST("EE", "233", "ESTONIA                                        "),
    ETH("ET", "231", "ETHIOPIA                                       "),
    FLK("FK", "238", "FALKLAND ISLANDS (MALVINAS)                    "),
    FRO("FO", "234", "FAROE ISLANDS                                  "),
    FJI("FJ", "242", "FIJI                                           "),
    FIN("FI", "246", "FINLAND                                        "),
    FRA("FR", "250", "FRANCE                                         "),
    GUF("GF", "254", "FRENCH GUIANA                                  "),
    PYF("PF", "258", "FRENCH POLYNESIA                               "),
    ATF("TF", "260", "FRENCH SOUTHERN TERRITORIES                    "),
    GAB("GA", "266", "GABON                                          "),
    GMB("GM", "270", "GAMBIA                                         "),
    GEO("GE", "268", "GEORGIA                                        "),
    DEU("DE", "276", "GERMANY                                        "),
    GHA("GH", "288", "GHANA                                          "),
    GIB("GI", "292", "GIBRALTAR                                      "),
    GRC("GR", "300", "GREECE                                         "),
    GRL("GL", "304", "GREENLAND                                      "),
    GRD("GD", "308", "GRENADA                                        "),
    GLP("GP", "312", "GUADELOUPE                                     "),
    GUM("GU", "316", "GUAM                                           "),
    GTM("GT", "320", "GUATEMALA                                      "),
    GIN("GN", "324", "GUINEA                                         "),
    GNB("GW", "624", "GUINEA-BISSAU                                  "),
    GUY("GY", "328", "GUYANA                                         "),
    HTI("HT", "332", "HAITI                                          "),
    HMD("HM", "334", "HEARD AND MC DONALD ISLANDS                    "),
    HND("HN", "340", "HONDURAS                                       "),
    HKG("HK", "344", "HONG KONG                                      "),
    HUN("HU", "348", "HUNGARY                                        "),
    ISL("IS", "352", "ICELAND                                        "),
    IND("IN", "356", "INDIA                                          "),
    IDN("ID", "360", "INDONESIA                                      "),
    IRN("IR", "364", "IRAN (ISLAMIC REPUBLIC OF)                     "),
    IRQ("IQ", "368", "IRAQ                                           "),
    IRL("IE", "372", "IRELAND                                        "),
    ISR("IL", "376", "ISRAEL                                         "),
    ITA("IT", "380", "ITALY                                          "),
    JAM("JM", "388", "JAMAICA                                        "),
    JPN("JP", "392", "JAPAN                                          "),
    JOR("JO", "400", "JORDAN                                         "),
    KAZ("KZ", "398", "KAZAKHSTAN                                     "),
    KEN("KE", "404", "KENYA                                          "),
    KIR("KI", "296", "KIRIBATI                                       "),
    PRK("KP", "408", "KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF         "),
    KOR("KR", "410", "KOREA, REPUBLIC OF                             "),
    KWT("KW", "414", "KUWAIT                                         "),
    KGZ("KG", "417", "KYRGYZSTAN                                     "),
    LAO("LA", "418", "LAO PEOPLE'S DEMOCRATIC REPUBLIC               "),
    LVA("LV", "428", "LATVIA                                         "),
    LBN("LB", "422", "LEBANON                                        "),
    LSO("LS", "426", "LESOTHO                                        "),
    LBR("LR", "430", "LIBERIA                                        "),
    LBY("LY", "434", "LIBYAN ARAB JAMAHIRIYA                         "),
    LIE("LI", "438", "LIECHTENSTEIN                                  "),
    LTU("LT", "440", "LITHUANIA                                      "),
    LUX("LU", "442", "LUXEMBOURG                                     "),
    MAC("MO", "446", "MACAU                                          "),
    MKD("MK", "807", "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF     "),
    MDG("MG", "450", "MADAGASCAR                                     "),
    MWI("MW", "454", "MALAWI                                         "),
    MYS("MY", "458", "MALAYSIA                                       "),
    MDV("MV", "462", "MALDIVES                                       "),
    MLI("ML", "466", "MALI                                           "),
    MLT("MT", "470", "MALTA                                          "),
    MHL("MH", "584", "MARSHALL ISLANDS                               "),
    MTQ("MQ", "474", "MARTINIQUE                                     "),
    MRT("MR", "478", "MAURITANIA                                     "),
    MUS("MU", "480", "MAURITIUS                                      "),
    MYT("YT", "175", "MAYOTTE                                        "),
    MEX("MX", "484", "MEXICO                                         "),
    FSM("FM", "583", "MICRONESIA, FEDERATED STATES OF                "),
    MDA("MD", "498", "MOLDOVA, REPUBLIC OF                           "),
    MCO("MC", "492", "MONACO                                         "),
    MNG("MN", "496", "MONGOLIA                                       "),
    MSR("MS", "500", "MONTSERRAT                                     "),
    MAR("MA", "504", "MOROCCO                                        "),
    MOZ("MZ", "508", "MOZAMBIQUE                                     "),
    MMR("MM", "104", "MYANMAR                                        "),
    NAM("NA", "516", "NAMIBIA                                        "),
    NRU("NR", "520", "NAURU                                          "),
    NPL("NP", "524", "NEPAL                                          "),
    NLD("NL", "528", "NETHERLANDS                                    "),
    ANT("AN", "530", "NETHERLANDS ANTILLES                           "),
    NCL("NC", "540", "NEW CALEDONIA                                  "),
    NZL("NZ", "554", "NEW ZEALAND                                    "),
    NIC("NI", "558", "NICARAGUA                                      "),
    NER("NE", "562", "NIGER                                          "),
    NGA("NG", "566", "NIGERIA                                        "),
    NIU("NU", "570", "NIUE                                           "),
    NFK("NF", "574", "NORFOLK ISLAND                                 "),
    MNP("MP", "580", "NORTHERN MARIANA ISLANDS                       "),
    NOR("NO", "578", "NORWAY                                         "),
    OMN("OM", "512", "OMAN                                           "),
    PAK("PK", "586", "PAKISTAN                                       "),
    PLW("PW", "585", "PALAU                                          "),
    PSE("PS", "275", "PALESTINIAN TERRITORY, Occupied                "),
    PAN("PA", "591", "PANAMA                                         "),
    PNG("PG", "598", "PAPUA NEW GUINEA                               "),
    PRY("PY", "600", "PARAGUAY                                       "),
    PER("PE", "604", "PERU                                           "),
    PHL("PH", "608", "PHILIPPINES                                    "),
    PCN("PN", "612", "PITCAIRN                                       "),
    POL("PL", "616", "POLAND                                         "),
    PRT("PT", "620", "PORTUGAL                                       "),
    PRI("PR", "630", "PUERTO RICO                                    "),
    QAT("QA", "634", "QATAR                                          "),
    REU("RE", "638", "REUNION                                        "),
    ROU("RO", "642", "ROMANIA                                        "),
    RUS("RU", "643", "RUSSIAN FEDERATION                             "),
    RWA("RW", "646", "RWANDA                                         "),
    SHN("SH", "654", "SAINT HELENA                                   "),
    KNA("KN", "659", "SAINT KITTS AND NEVIS                          "),
    LCA("LC", "662", "SAINT LUCIA                                    "),
    SPM("PM", "666", "SAINT PIERRE AND MIQUELON                      "),
    VCT("VC", "670", "SAINT VINCENT AND THE GRENADINES               "),
    WSM("WS", "882", "SAMOA                                          "),
    SMR("SM", "674", "SAN MARINO                                     "),
    STP("ST", "678", "SAO TOME AND PRINCIPE                          "),
    SAU("SA", "682", "SAUDI ARABIA                                   "),
    SEN("SN", "686", "SENEGAL                                        "),
    SCG("CS", "891", "SERBIA AND MONTENEGRO                          "),
    SYC("SC", "690", "SEYCHELLES                                     "),
    SLE("SL", "694", "SIERRA LEONE                                   "),
    SGP("SG", "702", "SINGAPORE                                      "),
    SVK("SK", "703", "SLOVAKIA                                       "),
    SVN("SI", "705", "SLOVENIA                                       "),
    SLB("SB", "090", "SOLOMON ISLANDS                                "),
    SOM("SO", "706", "SOMALIA                                        "),
    ZAF("ZA", "710", "SOUTH AFRICA                                   "),
    SGS("GS", "239", "SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS   "),
    ESP("ES", "724", "SPAIN                                          "),
    LKA("LK", "144", "SRI LANKA                                      "),
    SDN("SD", "736", "SUDAN                                          "),
    SUR("SR", "740", "SURINAME                                       "),
    SJM("SJ", "744", "SVALBARD AND JAN MAYEN ISLANDS                 "),
    SWZ("SZ", "748", "SWAZILAND                                      "),
    SWE("SE", "752", "SWEDEN                                         "),
    CHE("CH", "756", "SWITZERLAND                                    "),
    SYR("SY", "760", "SYRIAN ARAB REPUBLIC                           "),
    TWN("TW", "158", "TAIWAN                                         "),
    TJK("TJ", "762", "TAJIKISTAN                                     "),
    TZA("TZ", "834", "TANZANIA, UNITED REPUBLIC OF                   "),
    THA("TH", "764", "THAILAND                                       "),
    TLS("TL", "626", "TIMOR-LESTE                                    "),
    TGO("TG", "768", "TOGO                                           "),
    TKL("TK", "772", "TOKELAU                                        "),
    TON("TO", "776", "TONGA                                          "),
    TTO("TT", "780", "TRINIDAD AND TOBAGO                            "),
    TUN("TN", "788", "TUNISIA                                        "),
    TUR("TR", "792", "TURKEY                                         "),
    TKM("TM", "795", "TURKMENISTAN                                   "),
    TCA("TC", "796", "TURKS AND CAICOS ISLANDS                       "),
    TUV("TV", "798", "TUVALU                                         "),
    UGA("UG", "800", "UGANDA                                         "),
    UKR("UA", "804", "UKRAINE                                        "),
    ARE("AE", "784", "UNITED ARAB EMIRATES                           "),
    GBR("GB", "826", "UNITED KINGDOM                                 "),
    USA("US", "840", "UNITED STATES                                  "),
    UMI("UM", "581", "UNITED STATES MINOR OUTLYING ISLANDS           "),
    URY("UY", "858", "URUGUAY                                        "),
    UZB("UZ", "860", "UZBEKISTAN                                     "),
    VUT("VU", "548", "VANUATU                                        "),
    VAT("VA", "336", "VATICAN CITY STATE (HOLY SEE)                  "),
    VEN("VE", "862", "VENEZUELA                                      "),
    VNM("VN", "704", "VIET NAM                                       "),
    VGB("VG", "092", "VIRGIN ISLANDS (BRITISH)                       "),
    VIR("VI", "850", "VIRGIN ISLANDS (U.S.)                          "),
    WLF("WF", "876", "WALLIS AND FUTUNA ISLANDS                      "),
    ESH("EH", "732", "WESTERN SAHARA                                 "),
    YEM("YE", "887", "YEMEN                                          "),
    ZMB("ZM", "894", "ZAMBIA                                         "),
    ZWE("ZW", "716", "ZIMBABWE                                       ");

    public final String twoLetterCode;
    public final String number;
    public final String label;

    Country(String twoLetterCode, String number, String label) {
        this.twoLetterCode = twoLetterCode;
        this.number = number;
        this.label = label;
    }

    public static Country findCountry(String code) {
        for (Country country : Country.values()) {
            if (code.equalsIgnoreCase(country.name()) || code.equalsIgnoreCase(country.twoLetterCode) || code.equalsIgnoreCase(country.number))  {
                return country;
            }
        }

        return UNDEFINED;
    }

    public static Country findCountry(String code, CountryCoding countryCoding) {
        for (Country country : Country.values()) {
            switch (countryCoding) {
                case ISO_3166_1_ALPHA_2:
                    if (code.equalsIgnoreCase(country.twoLetterCode)) {
                        return country;
                    }
                    break;
                case ISO_3166_1_ALPHA_3:
                    if (code.equalsIgnoreCase(country.name())) {
                        return country;
                    }
                    break;
                case ISO_3166_1_NUMERIC:
                    if (code.equalsIgnoreCase(country.number)) {
                        return country;
                    }
                    break;
            }
        }
        return UNDEFINED;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy