View Javadoc
1   /*
2    * Copyright 2018-2020 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.bremersee.common.model;
18  
19  import com.fasterxml.jackson.annotation.JsonCreator;
20  import com.fasterxml.jackson.annotation.JsonValue;
21  import java.util.Arrays;
22  import java.util.Locale;
23  import java.util.MissingResourceException;
24  import java.util.regex.Pattern;
25  import org.springframework.util.StringUtils;
26  
27  /**
28   * ISO 3166-1 ALPHA-3 country codes from Java Locale.
29   *
30   * @author Christian Bremer
31   */
32  public enum ThreeLetterCountryCode {
33  
34    /**
35     * Aruba (ABW).
36     */
37    ABW("ABW", TwoLetterCountryCode.AW),
38  
39    /**
40     * Afghanistan (AFG).
41     */
42    AFG("AFG", TwoLetterCountryCode.AF),
43  
44    /**
45     * Angola (AGO).
46     */
47    AGO("AGO", TwoLetterCountryCode.AO),
48  
49    /**
50     * Anguilla (AIA).
51     */
52    AIA("AIA", TwoLetterCountryCode.AI),
53  
54    /**
55     * Ålandinseln (ALA).
56     */
57    ALA("ALA", TwoLetterCountryCode.AX),
58  
59    /**
60     * Albanien (ALB).
61     */
62    ALB("ALB", TwoLetterCountryCode.AL),
63  
64    /**
65     * Andorra (AND).
66     */
67    AND("AND", TwoLetterCountryCode.AD),
68  
69    /**
70     * Vereinigte Arabische Emirate (ARE).
71     */
72    ARE("ARE", TwoLetterCountryCode.AE),
73  
74    /**
75     * Argentinien (ARG).
76     */
77    ARG("ARG", TwoLetterCountryCode.AR),
78  
79    /**
80     * Armenien (ARM).
81     */
82    ARM("ARM", TwoLetterCountryCode.AM),
83  
84    /**
85     * Amerikanisch-Samoa (ASM).
86     */
87    ASM("ASM", TwoLetterCountryCode.AS),
88  
89    /**
90     * Antarktis (ATA).
91     */
92    ATA("ATA", TwoLetterCountryCode.AQ),
93  
94    /**
95     * Französische Süd- und Antarktisgebiete (ATF).
96     */
97    ATF("ATF", TwoLetterCountryCode.TF),
98  
99    /**
100    * Antigua und Barbuda (ATG).
101    */
102   ATG("ATG", TwoLetterCountryCode.AG),
103 
104   /**
105    * Australien (AUS).
106    */
107   AUS("AUS", TwoLetterCountryCode.AU),
108 
109   /**
110    * Österreich (AUT).
111    */
112   AUT("AUT", TwoLetterCountryCode.AT),
113 
114   /**
115    * Aserbaidschan (AZE).
116    */
117   AZE("AZE", TwoLetterCountryCode.AZ),
118 
119   /**
120    * Burundi (BDI).
121    */
122   BDI("BDI", TwoLetterCountryCode.BI),
123 
124   /**
125    * Belgien (BEL).
126    */
127   BEL("BEL", TwoLetterCountryCode.BE),
128 
129   /**
130    * Benin (BEN).
131    */
132   BEN("BEN", TwoLetterCountryCode.BJ),
133 
134   /**
135    * Bonaire, Sint Eustatius und Saba (BES).
136    */
137   BES("BES", TwoLetterCountryCode.BQ),
138 
139   /**
140    * Burkina Faso (BFA).
141    */
142   BFA("BFA", TwoLetterCountryCode.BF),
143 
144   /**
145    * Bangladesch (BGD).
146    */
147   BGD("BGD", TwoLetterCountryCode.BD),
148 
149   /**
150    * Bulgarien (BGR).
151    */
152   BGR("BGR", TwoLetterCountryCode.BG),
153 
154   /**
155    * Bahrain (BHR).
156    */
157   BHR("BHR", TwoLetterCountryCode.BH),
158 
159   /**
160    * Bahamas (BHS).
161    */
162   BHS("BHS", TwoLetterCountryCode.BS),
163 
164   /**
165    * Bosnien und Herzegowina (BIH).
166    */
167   BIH("BIH", TwoLetterCountryCode.BA),
168 
169   /**
170    * St. Barthélemy (BLM).
171    */
172   BLM("BLM", TwoLetterCountryCode.BL),
173 
174   /**
175    * Belarus (BLR).
176    */
177   BLR("BLR", TwoLetterCountryCode.BY),
178 
179   /**
180    * Belize (BLZ).
181    */
182   BLZ("BLZ", TwoLetterCountryCode.BZ),
183 
184   /**
185    * Bermuda (BMU).
186    */
187   BMU("BMU", TwoLetterCountryCode.BM),
188 
189   /**
190    * Bolivien (BOL).
191    */
192   BOL("BOL", TwoLetterCountryCode.BO),
193 
194   /**
195    * Brasilien (BRA).
196    */
197   BRA("BRA", TwoLetterCountryCode.BR),
198 
199   /**
200    * Barbados (BRB).
201    */
202   BRB("BRB", TwoLetterCountryCode.BB),
203 
204   /**
205    * Brunei Darussalam (BRN).
206    */
207   BRN("BRN", TwoLetterCountryCode.BN),
208 
209   /**
210    * Bhutan (BTN).
211    */
212   BTN("BTN", TwoLetterCountryCode.BT),
213 
214   /**
215    * Bouvetinsel (BVT).
216    */
217   BVT("BVT", TwoLetterCountryCode.BV),
218 
219   /**
220    * Botsuana (BWA).
221    */
222   BWA("BWA", TwoLetterCountryCode.BW),
223 
224   /**
225    * Zentralafrikanische Republik (CAF).
226    */
227   CAF("CAF", TwoLetterCountryCode.CF),
228 
229   /**
230    * Kanada (CAN).
231    */
232   CAN("CAN", TwoLetterCountryCode.CA),
233 
234   /**
235    * Kokosinseln (CCK).
236    */
237   CCK("CCK", TwoLetterCountryCode.CC),
238 
239   /**
240    * Schweiz (CHE).
241    */
242   CHE("CHE", TwoLetterCountryCode.CH),
243 
244   /**
245    * Chile (CHL).
246    */
247   CHL("CHL", TwoLetterCountryCode.CL),
248 
249   /**
250    * China (CHN).
251    */
252   CHN("CHN", TwoLetterCountryCode.CN),
253 
254   /**
255    * Côte d’Ivoire (CIV).
256    */
257   CIV("CIV", TwoLetterCountryCode.CI),
258 
259   /**
260    * Kamerun (CMR).
261    */
262   CMR("CMR", TwoLetterCountryCode.CM),
263 
264   /**
265    * Kongo-Kinshasa (COD).
266    */
267   COD("COD", TwoLetterCountryCode.CD),
268 
269   /**
270    * Kongo-Brazzaville (COG).
271    */
272   COG("COG", TwoLetterCountryCode.CG),
273 
274   /**
275    * Cookinseln (COK).
276    */
277   COK("COK", TwoLetterCountryCode.CK),
278 
279   /**
280    * Kolumbien (COL).
281    */
282   COL("COL", TwoLetterCountryCode.CO),
283 
284   /**
285    * Komoren (COM).
286    */
287   COM("COM", TwoLetterCountryCode.KM),
288 
289   /**
290    * Cabo Verde (CPV).
291    */
292   CPV("CPV", TwoLetterCountryCode.CV),
293 
294   /**
295    * Costa Rica (CRI).
296    */
297   CRI("CRI", TwoLetterCountryCode.CR),
298 
299   /**
300    * Kuba (CUB).
301    */
302   CUB("CUB", TwoLetterCountryCode.CU),
303 
304   /**
305    * Curaçao (CUW).
306    */
307   CUW("CUW", TwoLetterCountryCode.CW),
308 
309   /**
310    * Weihnachtsinsel (CXR).
311    */
312   CXR("CXR", TwoLetterCountryCode.CX),
313 
314   /**
315    * Kaimaninseln (CYM).
316    */
317   CYM("CYM", TwoLetterCountryCode.KY),
318 
319   /**
320    * Zypern (CYP).
321    */
322   CYP("CYP", TwoLetterCountryCode.CY),
323 
324   /**
325    * Tschechien (CZE).
326    */
327   CZE("CZE", TwoLetterCountryCode.CZ),
328 
329   /**
330    * Deutschland (DEU).
331    */
332   DEU("DEU", TwoLetterCountryCode.DE),
333 
334   /**
335    * Dschibuti (DJI).
336    */
337   DJI("DJI", TwoLetterCountryCode.DJ),
338 
339   /**
340    * Dominica (DMA).
341    */
342   DMA("DMA", TwoLetterCountryCode.DM),
343 
344   /**
345    * Dänemark (DNK).
346    */
347   DNK("DNK", TwoLetterCountryCode.DK),
348 
349   /**
350    * Dominikanische Republik (DOM).
351    */
352   DOM("DOM", TwoLetterCountryCode.DO),
353 
354   /**
355    * Algerien (DZA).
356    */
357   DZA("DZA", TwoLetterCountryCode.DZ),
358 
359   /**
360    * Ecuador (ECU).
361    */
362   ECU("ECU", TwoLetterCountryCode.EC),
363 
364   /**
365    * Ägypten (EGY).
366    */
367   EGY("EGY", TwoLetterCountryCode.EG),
368 
369   /**
370    * Eritrea (ERI).
371    */
372   ERI("ERI", TwoLetterCountryCode.ER),
373 
374   /**
375    * Westsahara (ESH).
376    */
377   ESH("ESH", TwoLetterCountryCode.EH),
378 
379   /**
380    * Spanien (ESP).
381    */
382   ESP("ESP", TwoLetterCountryCode.ES),
383 
384   /**
385    * Estland (EST).
386    */
387   EST("EST", TwoLetterCountryCode.EE),
388 
389   /**
390    * Äthiopien (ETH).
391    */
392   ETH("ETH", TwoLetterCountryCode.ET),
393 
394   /**
395    * Finnland (FIN).
396    */
397   FIN("FIN", TwoLetterCountryCode.FI),
398 
399   /**
400    * Fidschi (FJI).
401    */
402   FJI("FJI", TwoLetterCountryCode.FJ),
403 
404   /**
405    * Falklandinseln (FLK).
406    */
407   FLK("FLK", TwoLetterCountryCode.FK),
408 
409   /**
410    * Frankreich (FRA).
411    */
412   FRA("FRA", TwoLetterCountryCode.FR),
413 
414   /**
415    * Färöer (FRO).
416    */
417   FRO("FRO", TwoLetterCountryCode.FO),
418 
419   /**
420    * Mikronesien (FSM).
421    */
422   FSM("FSM", TwoLetterCountryCode.FM),
423 
424   /**
425    * Gabun (GAB).
426    */
427   GAB("GAB", TwoLetterCountryCode.GA),
428 
429   /**
430    * Vereinigtes Königreich (GBR).
431    */
432   GBR("GBR", TwoLetterCountryCode.GB),
433 
434   /**
435    * Georgien (GEO).
436    */
437   GEO("GEO", TwoLetterCountryCode.GE),
438 
439   /**
440    * Guernsey (GGY).
441    */
442   GGY("GGY", TwoLetterCountryCode.GG),
443 
444   /**
445    * Ghana (GHA).
446    */
447   GHA("GHA", TwoLetterCountryCode.GH),
448 
449   /**
450    * Gibraltar (GIB).
451    */
452   GIB("GIB", TwoLetterCountryCode.GI),
453 
454   /**
455    * Guinea (GIN).
456    */
457   GIN("GIN", TwoLetterCountryCode.GN),
458 
459   /**
460    * Guadeloupe (GLP).
461    */
462   GLP("GLP", TwoLetterCountryCode.GP),
463 
464   /**
465    * Gambia (GMB).
466    */
467   GMB("GMB", TwoLetterCountryCode.GM),
468 
469   /**
470    * Guinea-Bissau (GNB).
471    */
472   GNB("GNB", TwoLetterCountryCode.GW),
473 
474   /**
475    * Äquatorialguinea (GNQ).
476    */
477   GNQ("GNQ", TwoLetterCountryCode.GQ),
478 
479   /**
480    * Griechenland (GRC).
481    */
482   GRC("GRC", TwoLetterCountryCode.GR),
483 
484   /**
485    * Grenada (GRD).
486    */
487   GRD("GRD", TwoLetterCountryCode.GD),
488 
489   /**
490    * Grönland (GRL).
491    */
492   GRL("GRL", TwoLetterCountryCode.GL),
493 
494   /**
495    * Guatemala (GTM).
496    */
497   GTM("GTM", TwoLetterCountryCode.GT),
498 
499   /**
500    * Französisch-Guayana (GUF).
501    */
502   GUF("GUF", TwoLetterCountryCode.GF),
503 
504   /**
505    * Guam (GUM).
506    */
507   GUM("GUM", TwoLetterCountryCode.GU),
508 
509   /**
510    * Guyana (GUY).
511    */
512   GUY("GUY", TwoLetterCountryCode.GY),
513 
514   /**
515    * Sonderverwaltungsregion Hongkong (HKG).
516    */
517   HKG("HKG", TwoLetterCountryCode.HK),
518 
519   /**
520    * Heard und McDonaldinseln (HMD).
521    */
522   HMD("HMD", TwoLetterCountryCode.HM),
523 
524   /**
525    * Honduras (HND).
526    */
527   HND("HND", TwoLetterCountryCode.HN),
528 
529   /**
530    * Kroatien (HRV).
531    */
532   HRV("HRV", TwoLetterCountryCode.HR),
533 
534   /**
535    * Haiti (HTI).
536    */
537   HTI("HTI", TwoLetterCountryCode.HT),
538 
539   /**
540    * Ungarn (HUN).
541    */
542   HUN("HUN", TwoLetterCountryCode.HU),
543 
544   /**
545    * Indonesien (IDN).
546    */
547   IDN("IDN", TwoLetterCountryCode.ID),
548 
549   /**
550    * Isle of Man (IMN).
551    */
552   IMN("IMN", TwoLetterCountryCode.IM),
553 
554   /**
555    * Indien (IND).
556    */
557   IND("IND", TwoLetterCountryCode.IN),
558 
559   /**
560    * Britisches Territorium im Indischen Ozean (IOT).
561    */
562   IOT("IOT", TwoLetterCountryCode.IO),
563 
564   /**
565    * Irland (IRL).
566    */
567   IRL("IRL", TwoLetterCountryCode.IE),
568 
569   /**
570    * Iran (IRN).
571    */
572   IRN("IRN", TwoLetterCountryCode.IR),
573 
574   /**
575    * Irak (IRQ).
576    */
577   IRQ("IRQ", TwoLetterCountryCode.IQ),
578 
579   /**
580    * Island (ISL).
581    */
582   ISL("ISL", TwoLetterCountryCode.IS),
583 
584   /**
585    * Israel (ISR).
586    */
587   ISR("ISR", TwoLetterCountryCode.IL),
588 
589   /**
590    * Italien (ITA).
591    */
592   ITA("ITA", TwoLetterCountryCode.IT),
593 
594   /**
595    * Jamaika (JAM).
596    */
597   JAM("JAM", TwoLetterCountryCode.JM),
598 
599   /**
600    * Jersey (JEY).
601    */
602   JEY("JEY", TwoLetterCountryCode.JE),
603 
604   /**
605    * Jordanien (JOR).
606    */
607   JOR("JOR", TwoLetterCountryCode.JO),
608 
609   /**
610    * Japan (JPN).
611    */
612   JPN("JPN", TwoLetterCountryCode.JP),
613 
614   /**
615    * Kasachstan (KAZ).
616    */
617   KAZ("KAZ", TwoLetterCountryCode.KZ),
618 
619   /**
620    * Kenia (KEN).
621    */
622   KEN("KEN", TwoLetterCountryCode.KE),
623 
624   /**
625    * Kirgisistan (KGZ).
626    */
627   KGZ("KGZ", TwoLetterCountryCode.KG),
628 
629   /**
630    * Kambodscha (KHM).
631    */
632   KHM("KHM", TwoLetterCountryCode.KH),
633 
634   /**
635    * Kiribati (KIR).
636    */
637   KIR("KIR", TwoLetterCountryCode.KI),
638 
639   /**
640    * St. Kitts und Nevis (KNA).
641    */
642   KNA("KNA", TwoLetterCountryCode.KN),
643 
644   /**
645    * Südkorea (KOR).
646    */
647   KOR("KOR", TwoLetterCountryCode.KR),
648 
649   /**
650    * Kuwait (KWT).
651    */
652   KWT("KWT", TwoLetterCountryCode.KW),
653 
654   /**
655    * Laos (LAO).
656    */
657   LAO("LAO", TwoLetterCountryCode.LA),
658 
659   /**
660    * Libanon (LBN).
661    */
662   LBN("LBN", TwoLetterCountryCode.LB),
663 
664   /**
665    * Liberia (LBR).
666    */
667   LBR("LBR", TwoLetterCountryCode.LR),
668 
669   /**
670    * Libyen (LBY).
671    */
672   LBY("LBY", TwoLetterCountryCode.LY),
673 
674   /**
675    * St. Lucia (LCA).
676    */
677   LCA("LCA", TwoLetterCountryCode.LC),
678 
679   /**
680    * Liechtenstein (LIE).
681    */
682   LIE("LIE", TwoLetterCountryCode.LI),
683 
684   /**
685    * Sri Lanka (LKA).
686    */
687   LKA("LKA", TwoLetterCountryCode.LK),
688 
689   /**
690    * Lesotho (LSO).
691    */
692   LSO("LSO", TwoLetterCountryCode.LS),
693 
694   /**
695    * Litauen (LTU).
696    */
697   LTU("LTU", TwoLetterCountryCode.LT),
698 
699   /**
700    * Luxemburg (LUX).
701    */
702   LUX("LUX", TwoLetterCountryCode.LU),
703 
704   /**
705    * Lettland (LVA).
706    */
707   LVA("LVA", TwoLetterCountryCode.LV),
708 
709   /**
710    * Sonderverwaltungsregion Macau (MAC).
711    */
712   MAC("MAC", TwoLetterCountryCode.MO),
713 
714   /**
715    * St. Martin (MAF).
716    */
717   MAF("MAF", TwoLetterCountryCode.MF),
718 
719   /**
720    * Marokko (MAR).
721    */
722   MAR("MAR", TwoLetterCountryCode.MA),
723 
724   /**
725    * Monaco (MCO).
726    */
727   MCO("MCO", TwoLetterCountryCode.MC),
728 
729   /**
730    * Republik Moldau (MDA).
731    */
732   MDA("MDA", TwoLetterCountryCode.MD),
733 
734   /**
735    * Madagaskar (MDG).
736    */
737   MDG("MDG", TwoLetterCountryCode.MG),
738 
739   /**
740    * Malediven (MDV).
741    */
742   MDV("MDV", TwoLetterCountryCode.MV),
743 
744   /**
745    * Mexiko (MEX).
746    */
747   MEX("MEX", TwoLetterCountryCode.MX),
748 
749   /**
750    * Marshallinseln (MHL).
751    */
752   MHL("MHL", TwoLetterCountryCode.MH),
753 
754   /**
755    * Nordmazedonien (MKD).
756    */
757   MKD("MKD", TwoLetterCountryCode.MK),
758 
759   /**
760    * Mali (MLI).
761    */
762   MLI("MLI", TwoLetterCountryCode.ML),
763 
764   /**
765    * Malta (MLT).
766    */
767   MLT("MLT", TwoLetterCountryCode.MT),
768 
769   /**
770    * Myanmar (MMR).
771    */
772   MMR("MMR", TwoLetterCountryCode.MM),
773 
774   /**
775    * Montenegro (MNE).
776    */
777   MNE("MNE", TwoLetterCountryCode.ME),
778 
779   /**
780    * Mongolei (MNG).
781    */
782   MNG("MNG", TwoLetterCountryCode.MN),
783 
784   /**
785    * Nördliche Marianen (MNP).
786    */
787   MNP("MNP", TwoLetterCountryCode.MP),
788 
789   /**
790    * Mosambik (MOZ).
791    */
792   MOZ("MOZ", TwoLetterCountryCode.MZ),
793 
794   /**
795    * Mauretanien (MRT).
796    */
797   MRT("MRT", TwoLetterCountryCode.MR),
798 
799   /**
800    * Montserrat (MSR).
801    */
802   MSR("MSR", TwoLetterCountryCode.MS),
803 
804   /**
805    * Martinique (MTQ).
806    */
807   MTQ("MTQ", TwoLetterCountryCode.MQ),
808 
809   /**
810    * Mauritius (MUS).
811    */
812   MUS("MUS", TwoLetterCountryCode.MU),
813 
814   /**
815    * Malawi (MWI).
816    */
817   MWI("MWI", TwoLetterCountryCode.MW),
818 
819   /**
820    * Malaysia (MYS).
821    */
822   MYS("MYS", TwoLetterCountryCode.MY),
823 
824   /**
825    * Mayotte (MYT).
826    */
827   MYT("MYT", TwoLetterCountryCode.YT),
828 
829   /**
830    * Namibia (NAM).
831    */
832   NAM("NAM", TwoLetterCountryCode.NA),
833 
834   /**
835    * Neukaledonien (NCL).
836    */
837   NCL("NCL", TwoLetterCountryCode.NC),
838 
839   /**
840    * Niger (NER).
841    */
842   NER("NER", TwoLetterCountryCode.NE),
843 
844   /**
845    * Norfolkinsel (NFK).
846    */
847   NFK("NFK", TwoLetterCountryCode.NF),
848 
849   /**
850    * Nigeria (NGA).
851    */
852   NGA("NGA", TwoLetterCountryCode.NG),
853 
854   /**
855    * Nicaragua (NIC).
856    */
857   NIC("NIC", TwoLetterCountryCode.NI),
858 
859   /**
860    * Niue (NIU).
861    */
862   NIU("NIU", TwoLetterCountryCode.NU),
863 
864   /**
865    * Niederlande (NLD).
866    */
867   NLD("NLD", TwoLetterCountryCode.NL),
868 
869   /**
870    * Norwegen (NOR).
871    */
872   NOR("NOR", TwoLetterCountryCode.NO),
873 
874   /**
875    * Nepal (NPL).
876    */
877   NPL("NPL", TwoLetterCountryCode.NP),
878 
879   /**
880    * Nauru (NRU).
881    */
882   NRU("NRU", TwoLetterCountryCode.NR),
883 
884   /**
885    * Neuseeland (NZL).
886    */
887   NZL("NZL", TwoLetterCountryCode.NZ),
888 
889   /**
890    * Oman (OMN).
891    */
892   OMN("OMN", TwoLetterCountryCode.OM),
893 
894   /**
895    * Pakistan (PAK).
896    */
897   PAK("PAK", TwoLetterCountryCode.PK),
898 
899   /**
900    * Panama (PAN).
901    */
902   PAN("PAN", TwoLetterCountryCode.PA),
903 
904   /**
905    * Pitcairninseln (PCN).
906    */
907   PCN("PCN", TwoLetterCountryCode.PN),
908 
909   /**
910    * Peru (PER).
911    */
912   PER("PER", TwoLetterCountryCode.PE),
913 
914   /**
915    * Philippinen (PHL).
916    */
917   PHL("PHL", TwoLetterCountryCode.PH),
918 
919   /**
920    * Palau (PLW).
921    */
922   PLW("PLW", TwoLetterCountryCode.PW),
923 
924   /**
925    * Papua-Neuguinea (PNG).
926    */
927   PNG("PNG", TwoLetterCountryCode.PG),
928 
929   /**
930    * Polen (POL).
931    */
932   POL("POL", TwoLetterCountryCode.PL),
933 
934   /**
935    * Puerto Rico (PRI).
936    */
937   PRI("PRI", TwoLetterCountryCode.PR),
938 
939   /**
940    * Nordkorea (PRK).
941    */
942   PRK("PRK", TwoLetterCountryCode.KP),
943 
944   /**
945    * Portugal (PRT).
946    */
947   PRT("PRT", TwoLetterCountryCode.PT),
948 
949   /**
950    * Paraguay (PRY).
951    */
952   PRY("PRY", TwoLetterCountryCode.PY),
953 
954   /**
955    * Palästinensische Autonomiegebiete (PSE).
956    */
957   PSE("PSE", TwoLetterCountryCode.PS),
958 
959   /**
960    * Französisch-Polynesien (PYF).
961    */
962   PYF("PYF", TwoLetterCountryCode.PF),
963 
964   /**
965    * Katar (QAT).
966    */
967   QAT("QAT", TwoLetterCountryCode.QA),
968 
969   /**
970    * Réunion (REU).
971    */
972   REU("REU", TwoLetterCountryCode.RE),
973 
974   /**
975    * Rumänien (ROU).
976    */
977   ROU("ROU", TwoLetterCountryCode.RO),
978 
979   /**
980    * Russland (RUS).
981    */
982   RUS("RUS", TwoLetterCountryCode.RU),
983 
984   /**
985    * Ruanda (RWA).
986    */
987   RWA("RWA", TwoLetterCountryCode.RW),
988 
989   /**
990    * Saudi-Arabien (SAU).
991    */
992   SAU("SAU", TwoLetterCountryCode.SA),
993 
994   /**
995    * Sudan (SDN).
996    */
997   SDN("SDN", TwoLetterCountryCode.SD),
998 
999   /**
1000    * Senegal (SEN).
1001    */
1002   SEN("SEN", TwoLetterCountryCode.SN),
1003 
1004   /**
1005    * Singapur (SGP).
1006    */
1007   SGP("SGP", TwoLetterCountryCode.SG),
1008 
1009   /**
1010    * Südgeorgien und die Südlichen Sandwichinseln (SGS).
1011    */
1012   SGS("SGS", TwoLetterCountryCode.GS),
1013 
1014   /**
1015    * St. Helena (SHN).
1016    */
1017   SHN("SHN", TwoLetterCountryCode.SH),
1018 
1019   /**
1020    * Spitzbergen und Jan Mayen (SJM).
1021    */
1022   SJM("SJM", TwoLetterCountryCode.SJ),
1023 
1024   /**
1025    * Salomonen (SLB).
1026    */
1027   SLB("SLB", TwoLetterCountryCode.SB),
1028 
1029   /**
1030    * Sierra Leone (SLE).
1031    */
1032   SLE("SLE", TwoLetterCountryCode.SL),
1033 
1034   /**
1035    * El Salvador (SLV).
1036    */
1037   SLV("SLV", TwoLetterCountryCode.SV),
1038 
1039   /**
1040    * San Marino (SMR).
1041    */
1042   SMR("SMR", TwoLetterCountryCode.SM),
1043 
1044   /**
1045    * Somalia (SOM).
1046    */
1047   SOM("SOM", TwoLetterCountryCode.SO),
1048 
1049   /**
1050    * St. Pierre und Miquelon (SPM).
1051    */
1052   SPM("SPM", TwoLetterCountryCode.PM),
1053 
1054   /**
1055    * Serbien (SRB).
1056    */
1057   SRB("SRB", TwoLetterCountryCode.RS),
1058 
1059   /**
1060    * Südsudan (SSD).
1061    */
1062   SSD("SSD", TwoLetterCountryCode.SS),
1063 
1064   /**
1065    * São Tomé und Príncipe (STP).
1066    */
1067   STP("STP", TwoLetterCountryCode.ST),
1068 
1069   /**
1070    * Suriname (SUR).
1071    */
1072   SUR("SUR", TwoLetterCountryCode.SR),
1073 
1074   /**
1075    * Slowakei (SVK).
1076    */
1077   SVK("SVK", TwoLetterCountryCode.SK),
1078 
1079   /**
1080    * Slowenien (SVN).
1081    */
1082   SVN("SVN", TwoLetterCountryCode.SI),
1083 
1084   /**
1085    * Schweden (SWE).
1086    */
1087   SWE("SWE", TwoLetterCountryCode.SE),
1088 
1089   /**
1090    * Swasiland (SWZ).
1091    */
1092   SWZ("SWZ", TwoLetterCountryCode.SZ),
1093 
1094   /**
1095    * Sint Maarten (SXM).
1096    */
1097   SXM("SXM", TwoLetterCountryCode.SX),
1098 
1099   /**
1100    * Seychellen (SYC).
1101    */
1102   SYC("SYC", TwoLetterCountryCode.SC),
1103 
1104   /**
1105    * Syrien (SYR).
1106    */
1107   SYR("SYR", TwoLetterCountryCode.SY),
1108 
1109   /**
1110    * Turks- und Caicosinseln (TCA).
1111    */
1112   TCA("TCA", TwoLetterCountryCode.TC),
1113 
1114   /**
1115    * Tschad (TCD).
1116    */
1117   TCD("TCD", TwoLetterCountryCode.TD),
1118 
1119   /**
1120    * Togo (TGO).
1121    */
1122   TGO("TGO", TwoLetterCountryCode.TG),
1123 
1124   /**
1125    * Thailand (THA).
1126    */
1127   THA("THA", TwoLetterCountryCode.TH),
1128 
1129   /**
1130    * Tadschikistan (TJK).
1131    */
1132   TJK("TJK", TwoLetterCountryCode.TJ),
1133 
1134   /**
1135    * Tokelau (TKL).
1136    */
1137   TKL("TKL", TwoLetterCountryCode.TK),
1138 
1139   /**
1140    * Turkmenistan (TKM).
1141    */
1142   TKM("TKM", TwoLetterCountryCode.TM),
1143 
1144   /**
1145    * Timor-Leste (TLS).
1146    */
1147   TLS("TLS", TwoLetterCountryCode.TL),
1148 
1149   /**
1150    * Tonga (TON).
1151    */
1152   TON("TON", TwoLetterCountryCode.TO),
1153 
1154   /**
1155    * Trinidad und Tobago (TTO).
1156    */
1157   TTO("TTO", TwoLetterCountryCode.TT),
1158 
1159   /**
1160    * Tunesien (TUN).
1161    */
1162   TUN("TUN", TwoLetterCountryCode.TN),
1163 
1164   /**
1165    * Türkei (TUR).
1166    */
1167   TUR("TUR", TwoLetterCountryCode.TR),
1168 
1169   /**
1170    * Tuvalu (TUV).
1171    */
1172   TUV("TUV", TwoLetterCountryCode.TV),
1173 
1174   /**
1175    * Taiwan (TWN).
1176    */
1177   TWN("TWN", TwoLetterCountryCode.TW),
1178 
1179   /**
1180    * Tansania (TZA).
1181    */
1182   TZA("TZA", TwoLetterCountryCode.TZ),
1183 
1184   /**
1185    * Uganda (UGA).
1186    */
1187   UGA("UGA", TwoLetterCountryCode.UG),
1188 
1189   /**
1190    * Ukraine (UKR).
1191    */
1192   UKR("UKR", TwoLetterCountryCode.UA),
1193 
1194   /**
1195    * Amerikanische Überseeinseln (UMI).
1196    */
1197   UMI("UMI", TwoLetterCountryCode.UM),
1198 
1199   /**
1200    * Uruguay (URY).
1201    */
1202   URY("URY", TwoLetterCountryCode.UY),
1203 
1204   /**
1205    * Vereinigte Staaten (USA).
1206    */
1207   USA("USA", TwoLetterCountryCode.US),
1208 
1209   /**
1210    * Usbekistan (UZB).
1211    */
1212   UZB("UZB", TwoLetterCountryCode.UZ),
1213 
1214   /**
1215    * Vatikanstadt (VAT).
1216    */
1217   VAT("VAT", TwoLetterCountryCode.VA),
1218 
1219   /**
1220    * St. Vincent und die Grenadinen (VCT).
1221    */
1222   VCT("VCT", TwoLetterCountryCode.VC),
1223 
1224   /**
1225    * Venezuela (VEN).
1226    */
1227   VEN("VEN", TwoLetterCountryCode.VE),
1228 
1229   /**
1230    * Britische Jungferninseln (VGB).
1231    */
1232   VGB("VGB", TwoLetterCountryCode.VG),
1233 
1234   /**
1235    * Amerikanische Jungferninseln (VIR).
1236    */
1237   VIR("VIR", TwoLetterCountryCode.VI),
1238 
1239   /**
1240    * Vietnam (VNM).
1241    */
1242   VNM("VNM", TwoLetterCountryCode.VN),
1243 
1244   /**
1245    * Vanuatu (VUT).
1246    */
1247   VUT("VUT", TwoLetterCountryCode.VU),
1248 
1249   /**
1250    * Wallis und Futuna (WLF).
1251    */
1252   WLF("WLF", TwoLetterCountryCode.WF),
1253 
1254   /**
1255    * Samoa (WSM).
1256    */
1257   WSM("WSM", TwoLetterCountryCode.WS),
1258 
1259   /**
1260    * Jemen (YEM).
1261    */
1262   YEM("YEM", TwoLetterCountryCode.YE),
1263 
1264   /**
1265    * Südafrika (ZAF).
1266    */
1267   ZAF("ZAF", TwoLetterCountryCode.ZA),
1268 
1269   /**
1270    * Sambia (ZMB).
1271    */
1272   ZMB("ZMB", TwoLetterCountryCode.ZM),
1273 
1274   /**
1275    * Simbabwe (ZWE).
1276    */
1277   ZWE("ZWE", TwoLetterCountryCode.ZW);
1278 
1279   private final String value;
1280 
1281   private final TwoLetterCountryCode twoLetterCountryCode;
1282 
1283   ThreeLetterCountryCode(final String value, final TwoLetterCountryCode twoLetterCountryCode) {
1284     this.value = value;
1285     this.twoLetterCountryCode = twoLetterCountryCode;
1286   }
1287 
1288   /**
1289    * Gets two letter country code.
1290    *
1291    * @return the two letter country code
1292    */
1293   public TwoLetterCountryCode getTwoLetterCountryCode() {
1294     return twoLetterCountryCode;
1295   }
1296 
1297   /**
1298    * Has two letter country code boolean.
1299    *
1300    * @return the boolean
1301    */
1302   public boolean hasTwoLetterCountryCode() {
1303     return twoLetterCountryCode != null;
1304   }
1305 
1306   @Override
1307   @JsonValue
1308   public String toString() {
1309     return value;
1310   }
1311 
1312   /**
1313    * To locale.
1314    *
1315    * @return the locale
1316    */
1317   public Locale toLocale() {
1318     return Arrays
1319         .stream(Locale.getAvailableLocales())
1320         .filter(this::hasIsoCountry)
1321         .filter(locale -> value.equalsIgnoreCase(locale.getISO3Country()))
1322         .findAny()
1323         .map(locale -> new Locale("", locale.getCountry()))
1324         .orElseGet(() -> Arrays.stream(Locale.getISOCountries())
1325             .map(iso -> new Locale("", iso))
1326             .filter(this::hasIsoCountry)
1327             .filter(locale -> value.equalsIgnoreCase(locale.getISO3Country()))
1328             .findAny()
1329             .map(locale -> new Locale("", locale.getCountry()))
1330             .orElse(null));
1331   }
1332 
1333   private boolean hasIsoCountry(final Locale locale) {
1334     try {
1335       return StringUtils.hasText(locale.getISO3Country());
1336     } catch (MissingResourceException e) {
1337       return false;
1338     }
1339   }
1340 
1341   /**
1342    * From three letter country code.
1343    *
1344    * @param text the text
1345    * @return the three letter country code
1346    */
1347   @JsonCreator
1348   public static ThreeLetterCountryCode fromValue(final String text) {
1349     return fromValue(text, null);
1350   }
1351 
1352   /**
1353    * From value three letter country code.
1354    *
1355    * @param text the text
1356    * @param defaultCode the default code
1357    * @return the three letter country code
1358    */
1359   @SuppressWarnings("DuplicatedCode")
1360   public static ThreeLetterCountryCode fromValue(
1361       final String text,
1362       final ThreeLetterCountryCode defaultCode) {
1363 
1364     String source = text != null ? text.trim().toUpperCase() : null;
1365     if (source == null || source.length() < 2) {
1366       return defaultCode;
1367     }
1368     source = source.replace("-", "_");
1369     String[] parts = source.split(Pattern.quote("_"));
1370     source = parts.length > 1 ? parts[1].trim() : parts[0].trim();
1371     for (ThreeLetterCountryCode b : ThreeLetterCountryCode.values()) {
1372       if (b.value.equals(source)
1373           || (b.twoLetterCountryCode != null && b.twoLetterCountryCode.toString().equals(source))) {
1374         return b;
1375       }
1376     }
1377     return defaultCode;
1378   }
1379 
1380   /**
1381    * From locale.
1382    *
1383    * @param locale the locale
1384    * @return the three letter country code
1385    */
1386   public static ThreeLetterCountryCode fromLocale(final Locale locale) {
1387     return fromLocale(locale, null);
1388   }
1389 
1390   /**
1391    * From locale three letter country code.
1392    *
1393    * @param locale the locale
1394    * @param defaultCode the default code
1395    * @return the three letter country code
1396    */
1397   public static ThreeLetterCountryCode fromLocale(
1398       final Locale locale,
1399       final ThreeLetterCountryCode defaultCode) {
1400     if (locale == null || !StringUtils.hasText(locale.getISO3Country())) {
1401       return defaultCode;
1402     }
1403     return fromValue(locale.getISO3Country(), defaultCode);
1404   }
1405 
1406 }
1407