app/model/Country.scala (261 lines of code) (raw):

package model import scala.util.Try enum Country( // ISO 3166-1 alpha 2 "short" code format val code: String, val name: String ) { case AD extends Country("AD", "Andorra") case AE extends Country("AE", "United Arab Emirates") case AF extends Country("AF", "Afghanistan") case AG extends Country("AG", "Antigua & Barbuda") case AI extends Country("AI", "Anguilla") case AL extends Country("AL", "Albania") case AM extends Country("AM", "Armenia") case AO extends Country("AO", "Angola") case AQ extends Country("AQ", "Antarctica") case AR extends Country("AR", "Argentina") case AS extends Country("AS", "American Samoa") case AT extends Country("AT", "Austria") case AU extends Country("AU", "Australia") case AW extends Country("AW", "Aruba") case AX extends Country("AX", "Åland Islands") case AZ extends Country("AZ", "Azerbaijan") case BA extends Country("BA", "Bosnia-Herzegovina") case BB extends Country("BB", "Barbados") case BD extends Country("BD", "Bangladesh") case BE extends Country("BE", "Belgium") case BF extends Country("BF", "Burkina Faso") case BG extends Country("BG", "Bulgaria") case BH extends Country("BH", "Bahrain") case BI extends Country("BI", "Burundi") case BJ extends Country("BJ", "Benin") case BL extends Country("BL", "Saint Barthélemy") case BM extends Country("BM", "Bermuda") case BN extends Country("BN", "Brunei Darussalam") case BO extends Country("BO", "Bolivia") case BQ extends Country("BQ", "Bonaire, Saint Eustatius and Saba") case BR extends Country("BR", "Brazil") case BS extends Country("BS", "Bahamas") case BT extends Country("BT", "Bhutan") case BV extends Country("BV", "Bouvet Island") case BW extends Country("BW", "Botswana") case BY extends Country("BY", "Belarus") case BZ extends Country("BZ", "Belize") case CA extends Country("CA", "Canada") case CC extends Country("CC", "Cocos (Keeling) Islands") case CD extends Country("CD", "Congo (Kinshasa)") case CF extends Country("CF", "Central African Republic") case CG extends Country("CG", "Congo (Brazzaville)") case CH extends Country("CH", "Switzerland") case CI extends Country("CI", "Ivory Coast") case CK extends Country("CK", "Cook Islands") case CL extends Country("CL", "Chile") case CM extends Country("CM", "Cameroon") case CN extends Country("CN", "China") case CO extends Country("CO", "Colombia") case CR extends Country("CR", "Costa Rica") case CU extends Country("CU", "Cuba") case CV extends Country("CV", "Cape Verde Islands") case CW extends Country("CW", "Curaçao") case CX extends Country("CX", "Christmas Island") case CY extends Country("CY", "Cyprus") case CZ extends Country("CZ", "Czech Republic") case DE extends Country("DE", "Germany") case DJ extends Country("DJ", "Djibouti") case DK extends Country("DK", "Denmark") case DM extends Country("DM", "Dominica") case DO extends Country("DO", "Dominican Republic") case DZ extends Country("DZ", "Algeria") case EC extends Country("EC", "Ecuador") case EE extends Country("EE", "Estonia") case EG extends Country("EG", "Egypt") case EH extends Country("EH", "Western Sahara") case ER extends Country("ER", "Eritrea") case ES extends Country("ES", "Spain") case ET extends Country("ET", "Ethiopia") case FI extends Country("FI", "Finland") case FJ extends Country("FJ", "Fiji") case FK extends Country("FK", "Falkland Islands") case FM extends Country("FM", "Micronesia") case FO extends Country("FO", "Faroe Islands") case FR extends Country("FR", "France") case GA extends Country("GA", "Gabon") case GB extends Country("GB", "United Kingdom") case GD extends Country("GD", "Grenada") case GE extends Country("GE", "Georgia") case GF extends Country("GF", "French Guiana") case GG extends Country("GG", "Guernsey") case GH extends Country("GH", "Ghana") case GI extends Country("GI", "Gibraltar") case GL extends Country("GL", "Greenland") case GM extends Country("GM", "Gambia") case GN extends Country("GN", "Guinea") case GP extends Country("GP", "Guadeloupe") case GQ extends Country("GQ", "Equatorial Guinea") case GR extends Country("GR", "Greece") case GS extends Country("GS", "South Georgia & The South Sandwich Islands") case GT extends Country("GT", "Guatemala") case GU extends Country("GU", "Guam") case GW extends Country("GW", "Guinea-Bissau") case GY extends Country("GY", "Guyana") case HK extends Country("HK", "Hong Kong") case HM extends Country("HM", "Heard Island and McDonald Islands") case HN extends Country("HN", "Honduras") case HR extends Country("HR", "Croatia") case HT extends Country("HT", "Haiti") case HU extends Country("HU", "Hungary") case ID extends Country("ID", "Indonesia") case IE extends Country("IE", "Ireland") case IL extends Country("IL", "Israel") case IM extends Country("IM", "Isle of Man") case IN extends Country("IN", "India") case IO extends Country("IO", "British Indian Ocean Territory") case IQ extends Country("IQ", "Iraq") case IR extends Country("IR", "Iran") case IS extends Country("IS", "Iceland") case IT extends Country("IT", "Italy") case JE extends Country("JE", "Jersey") case JM extends Country("JM", "Jamaica") case JO extends Country("JO", "Jordan") case JP extends Country("JP", "Japan") case KE extends Country("KE", "Kenya") case KG extends Country("KG", "Kyrgyzstan") case KH extends Country("KH", "Cambodia") case KI extends Country("KI", "Kiribati") case KM extends Country("KM", "Comoros") case KN extends Country("KN", "Saint Christopher & Nevis") case KP extends Country("KP", "North Korea") case KR extends Country("KR", "South Korea") case KW extends Country("KW", "Kuwait") case KY extends Country("KY", "Cayman Islands") case KZ extends Country("KZ", "Kazakhstan") case LA extends Country("LA", "Laos") case LB extends Country("LB", "Lebanon") case LC extends Country("LC", "Saint Lucia") case LI extends Country("LI", "Liechtenstein") case LK extends Country("LK", "Sri Lanka") case LR extends Country("LR", "Liberia") case LS extends Country("LS", "Lesotho") case LT extends Country("LT", "Lithuania") case LU extends Country("LU", "Luxembourg") case LV extends Country("LV", "Latvia") case LY extends Country("LY", "Libya") case MA extends Country("MA", "Morocco") case MC extends Country("MC", "Monaco") case MD extends Country("MD", "Moldova") case ME extends Country("ME", "Montenegro") case MF extends Country("MF", "Saint Martin") case MG extends Country("MG", "Madagascar") case MH extends Country("MH", "Marshall Islands") case MK extends Country("MK", "Macedonia") case ML extends Country("ML", "Mali") case MM extends Country("MM", "Myanmar") case MN extends Country("MN", "Mongolia") case MO extends Country("MO", "Macau") case MP extends Country("MP", "Northern Mariana Islands") case MQ extends Country("MQ", "Martinique") case MR extends Country("MR", "Mauritania") case MS extends Country("MS", "Montserrat") case MT extends Country("MT", "Malta") case MU extends Country("MU", "Mauritius") case MV extends Country("MV", "Maldives") case MW extends Country("MW", "Malawi") case MX extends Country("MX", "Mexico") case MY extends Country("MY", "Malaysia") case MZ extends Country("MZ", "Mozambique") case NA extends Country("NA", "Namibia") case NC extends Country("NC", "New Caledonia") case NE extends Country("NE", "Niger") case NF extends Country("NF", "Norfolk Island") case NG extends Country("NG", "Nigeria") case NI extends Country("NI", "Nicaragua") case NL extends Country("NL", "Netherlands") case NO extends Country("NO", "Norway") case NP extends Country("NP", "Nepal") case NR extends Country("NR", "Nauru") case NU extends Country("NU", "Niue") case NZ extends Country("NZ", "New Zealand") case OM extends Country("OM", "Oman") case PA extends Country("PA", "Panama") case PE extends Country("PE", "Peru") case PF extends Country("PF", "French Polynesia") case PG extends Country("PG", "Papua New Guinea") case PH extends Country("PH", "Philippines") case PK extends Country("PK", "Pakistan") case PL extends Country("PL", "Poland") case PM extends Country("PM", "Saint Pierre & Miquelon") case PN extends Country("PN", "Pitcairn Islands") case PR extends Country("PR", "Puerto Rico") case PS extends Country("PS", "Palestinian Territories") case PT extends Country("PT", "Portugal") case PW extends Country("PW", "Palau") case PY extends Country("PY", "Paraguay") case QA extends Country("QA", "Qatar") case RE extends Country("RE", "Réunion") case RO extends Country("RO", "Romania") case RS extends Country("RS", "Serbia") case RU extends Country("RU", "Russia") case RW extends Country("RW", "Rwanda") case SA extends Country("SA", "Saudi Arabia") case SB extends Country("SB", "Solomon Islands") case SC extends Country("SC", "Seychelles") case SD extends Country("SD", "Sudan") case SE extends Country("SE", "Sweden") case SG extends Country("SG", "Singapore") case SH extends Country("SH", "Saint Helena") case SI extends Country("SI", "Slovenia") case SJ extends Country("SJ", "Svalbard and Jan Mayen") case SK extends Country("SK", "Slovakia") case SL extends Country("SL", "Sierra Leone") case SM extends Country("SM", "San Marino") case SN extends Country("SN", "Senegal") case SO extends Country("SO", "Somalia") case SR extends Country("SR", "Suriname") case SS extends Country("SS", "South Sudan") case ST extends Country("ST", "Sao Tome & Principe") case SV extends Country("SV", "El Salvador") case SX extends Country("SX", "Sint Maarten") case SY extends Country("SY", "Syria") case SZ extends Country("SZ", "Swaziland") case TC extends Country("TC", "Turks & Caicos Islands") case TD extends Country("TD", "Chad") case TF extends Country("TF", "French Southern Territories") case TG extends Country("TG", "Togo") case TH extends Country("TH", "Thailand") case TJ extends Country("TJ", "Tajikistan") case TK extends Country("TK", "Tokelau") case TL extends Country("TL", "East Timor") case TM extends Country("TM", "Turkmenistan") case TN extends Country("TN", "Tunisia") case TO extends Country("TO", "Tonga") case TR extends Country("TR", "Turkey") case TT extends Country("TT", "Trinidad & Tobago") case TV extends Country("TV", "Tuvalu") case TW extends Country("TW", "Taiwan") case TZ extends Country("TZ", "Tanzania") case UA extends Country("UA", "Ukraine") case UG extends Country("UG", "Uganda") case UM extends Country("UM", "United States Minor Outlying Islands") case US extends Country("US", "United States") case UY extends Country("UY", "Uruguay") case UZ extends Country("UZ", "Uzbekistan") case VA extends Country("VA", "Holy See") case VC extends Country("VC", "Saint Vincent & The Grenadines") case VE extends Country("VE", "Venezuela") case VG extends Country("VG", "British Virgin Islands") case VI extends Country("VI", "United States Virgin Islands") case VN extends Country("VN", "Vietnam") case VU extends Country("VU", "Vanuatu") case WF extends Country("WF", "Wallis & Futuna") case WS extends Country("WS", "Samoa") case YE extends Country("YE", "Yemen") case YT extends Country("YT", "Mayotte") case ZA extends Country("ZA", "South Africa") case ZM extends Country("ZM", "Zambia") case ZW extends Country("ZW", "Zimbabwe") } object Country { private val countriesByName: Map[String, Country] = Country.values.map(c => c.name -> c).toMap def findByName(name: String): Option[Country] = countriesByName.get(name) def findByCode(code: String): Option[Country] = Try(Country.valueOf(code)).toOption }