1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
29
30
31
32 public enum ThreeLetterCountryCode {
33
34
35
36
37 ABW("ABW", TwoLetterCountryCode.AW),
38
39
40
41
42 AFG("AFG", TwoLetterCountryCode.AF),
43
44
45
46
47 AGO("AGO", TwoLetterCountryCode.AO),
48
49
50
51
52 AIA("AIA", TwoLetterCountryCode.AI),
53
54
55
56
57 ALA("ALA", TwoLetterCountryCode.AX),
58
59
60
61
62 ALB("ALB", TwoLetterCountryCode.AL),
63
64
65
66
67 AND("AND", TwoLetterCountryCode.AD),
68
69
70
71
72 ARE("ARE", TwoLetterCountryCode.AE),
73
74
75
76
77 ARG("ARG", TwoLetterCountryCode.AR),
78
79
80
81
82 ARM("ARM", TwoLetterCountryCode.AM),
83
84
85
86
87 ASM("ASM", TwoLetterCountryCode.AS),
88
89
90
91
92 ATA("ATA", TwoLetterCountryCode.AQ),
93
94
95
96
97 ATF("ATF", TwoLetterCountryCode.TF),
98
99
100
101
102 ATG("ATG", TwoLetterCountryCode.AG),
103
104
105
106
107 AUS("AUS", TwoLetterCountryCode.AU),
108
109
110
111
112 AUT("AUT", TwoLetterCountryCode.AT),
113
114
115
116
117 AZE("AZE", TwoLetterCountryCode.AZ),
118
119
120
121
122 BDI("BDI", TwoLetterCountryCode.BI),
123
124
125
126
127 BEL("BEL", TwoLetterCountryCode.BE),
128
129
130
131
132 BEN("BEN", TwoLetterCountryCode.BJ),
133
134
135
136
137 BES("BES", TwoLetterCountryCode.BQ),
138
139
140
141
142 BFA("BFA", TwoLetterCountryCode.BF),
143
144
145
146
147 BGD("BGD", TwoLetterCountryCode.BD),
148
149
150
151
152 BGR("BGR", TwoLetterCountryCode.BG),
153
154
155
156
157 BHR("BHR", TwoLetterCountryCode.BH),
158
159
160
161
162 BHS("BHS", TwoLetterCountryCode.BS),
163
164
165
166
167 BIH("BIH", TwoLetterCountryCode.BA),
168
169
170
171
172 BLM("BLM", TwoLetterCountryCode.BL),
173
174
175
176
177 BLR("BLR", TwoLetterCountryCode.BY),
178
179
180
181
182 BLZ("BLZ", TwoLetterCountryCode.BZ),
183
184
185
186
187 BMU("BMU", TwoLetterCountryCode.BM),
188
189
190
191
192 BOL("BOL", TwoLetterCountryCode.BO),
193
194
195
196
197 BRA("BRA", TwoLetterCountryCode.BR),
198
199
200
201
202 BRB("BRB", TwoLetterCountryCode.BB),
203
204
205
206
207 BRN("BRN", TwoLetterCountryCode.BN),
208
209
210
211
212 BTN("BTN", TwoLetterCountryCode.BT),
213
214
215
216
217 BVT("BVT", TwoLetterCountryCode.BV),
218
219
220
221
222 BWA("BWA", TwoLetterCountryCode.BW),
223
224
225
226
227 CAF("CAF", TwoLetterCountryCode.CF),
228
229
230
231
232 CAN("CAN", TwoLetterCountryCode.CA),
233
234
235
236
237 CCK("CCK", TwoLetterCountryCode.CC),
238
239
240
241
242 CHE("CHE", TwoLetterCountryCode.CH),
243
244
245
246
247 CHL("CHL", TwoLetterCountryCode.CL),
248
249
250
251
252 CHN("CHN", TwoLetterCountryCode.CN),
253
254
255
256
257 CIV("CIV", TwoLetterCountryCode.CI),
258
259
260
261
262 CMR("CMR", TwoLetterCountryCode.CM),
263
264
265
266
267 COD("COD", TwoLetterCountryCode.CD),
268
269
270
271
272 COG("COG", TwoLetterCountryCode.CG),
273
274
275
276
277 COK("COK", TwoLetterCountryCode.CK),
278
279
280
281
282 COL("COL", TwoLetterCountryCode.CO),
283
284
285
286
287 COM("COM", TwoLetterCountryCode.KM),
288
289
290
291
292 CPV("CPV", TwoLetterCountryCode.CV),
293
294
295
296
297 CRI("CRI", TwoLetterCountryCode.CR),
298
299
300
301
302 CUB("CUB", TwoLetterCountryCode.CU),
303
304
305
306
307 CUW("CUW", TwoLetterCountryCode.CW),
308
309
310
311
312 CXR("CXR", TwoLetterCountryCode.CX),
313
314
315
316
317 CYM("CYM", TwoLetterCountryCode.KY),
318
319
320
321
322 CYP("CYP", TwoLetterCountryCode.CY),
323
324
325
326
327 CZE("CZE", TwoLetterCountryCode.CZ),
328
329
330
331
332 DEU("DEU", TwoLetterCountryCode.DE),
333
334
335
336
337 DJI("DJI", TwoLetterCountryCode.DJ),
338
339
340
341
342 DMA("DMA", TwoLetterCountryCode.DM),
343
344
345
346
347 DNK("DNK", TwoLetterCountryCode.DK),
348
349
350
351
352 DOM("DOM", TwoLetterCountryCode.DO),
353
354
355
356
357 DZA("DZA", TwoLetterCountryCode.DZ),
358
359
360
361
362 ECU("ECU", TwoLetterCountryCode.EC),
363
364
365
366
367 EGY("EGY", TwoLetterCountryCode.EG),
368
369
370
371
372 ERI("ERI", TwoLetterCountryCode.ER),
373
374
375
376
377 ESH("ESH", TwoLetterCountryCode.EH),
378
379
380
381
382 ESP("ESP", TwoLetterCountryCode.ES),
383
384
385
386
387 EST("EST", TwoLetterCountryCode.EE),
388
389
390
391
392 ETH("ETH", TwoLetterCountryCode.ET),
393
394
395
396
397 FIN("FIN", TwoLetterCountryCode.FI),
398
399
400
401
402 FJI("FJI", TwoLetterCountryCode.FJ),
403
404
405
406
407 FLK("FLK", TwoLetterCountryCode.FK),
408
409
410
411
412 FRA("FRA", TwoLetterCountryCode.FR),
413
414
415
416
417 FRO("FRO", TwoLetterCountryCode.FO),
418
419
420
421
422 FSM("FSM", TwoLetterCountryCode.FM),
423
424
425
426
427 GAB("GAB", TwoLetterCountryCode.GA),
428
429
430
431
432 GBR("GBR", TwoLetterCountryCode.GB),
433
434
435
436
437 GEO("GEO", TwoLetterCountryCode.GE),
438
439
440
441
442 GGY("GGY", TwoLetterCountryCode.GG),
443
444
445
446
447 GHA("GHA", TwoLetterCountryCode.GH),
448
449
450
451
452 GIB("GIB", TwoLetterCountryCode.GI),
453
454
455
456
457 GIN("GIN", TwoLetterCountryCode.GN),
458
459
460
461
462 GLP("GLP", TwoLetterCountryCode.GP),
463
464
465
466
467 GMB("GMB", TwoLetterCountryCode.GM),
468
469
470
471
472 GNB("GNB", TwoLetterCountryCode.GW),
473
474
475
476
477 GNQ("GNQ", TwoLetterCountryCode.GQ),
478
479
480
481
482 GRC("GRC", TwoLetterCountryCode.GR),
483
484
485
486
487 GRD("GRD", TwoLetterCountryCode.GD),
488
489
490
491
492 GRL("GRL", TwoLetterCountryCode.GL),
493
494
495
496
497 GTM("GTM", TwoLetterCountryCode.GT),
498
499
500
501
502 GUF("GUF", TwoLetterCountryCode.GF),
503
504
505
506
507 GUM("GUM", TwoLetterCountryCode.GU),
508
509
510
511
512 GUY("GUY", TwoLetterCountryCode.GY),
513
514
515
516
517 HKG("HKG", TwoLetterCountryCode.HK),
518
519
520
521
522 HMD("HMD", TwoLetterCountryCode.HM),
523
524
525
526
527 HND("HND", TwoLetterCountryCode.HN),
528
529
530
531
532 HRV("HRV", TwoLetterCountryCode.HR),
533
534
535
536
537 HTI("HTI", TwoLetterCountryCode.HT),
538
539
540
541
542 HUN("HUN", TwoLetterCountryCode.HU),
543
544
545
546
547 IDN("IDN", TwoLetterCountryCode.ID),
548
549
550
551
552 IMN("IMN", TwoLetterCountryCode.IM),
553
554
555
556
557 IND("IND", TwoLetterCountryCode.IN),
558
559
560
561
562 IOT("IOT", TwoLetterCountryCode.IO),
563
564
565
566
567 IRL("IRL", TwoLetterCountryCode.IE),
568
569
570
571
572 IRN("IRN", TwoLetterCountryCode.IR),
573
574
575
576
577 IRQ("IRQ", TwoLetterCountryCode.IQ),
578
579
580
581
582 ISL("ISL", TwoLetterCountryCode.IS),
583
584
585
586
587 ISR("ISR", TwoLetterCountryCode.IL),
588
589
590
591
592 ITA("ITA", TwoLetterCountryCode.IT),
593
594
595
596
597 JAM("JAM", TwoLetterCountryCode.JM),
598
599
600
601
602 JEY("JEY", TwoLetterCountryCode.JE),
603
604
605
606
607 JOR("JOR", TwoLetterCountryCode.JO),
608
609
610
611
612 JPN("JPN", TwoLetterCountryCode.JP),
613
614
615
616
617 KAZ("KAZ", TwoLetterCountryCode.KZ),
618
619
620
621
622 KEN("KEN", TwoLetterCountryCode.KE),
623
624
625
626
627 KGZ("KGZ", TwoLetterCountryCode.KG),
628
629
630
631
632 KHM("KHM", TwoLetterCountryCode.KH),
633
634
635
636
637 KIR("KIR", TwoLetterCountryCode.KI),
638
639
640
641
642 KNA("KNA", TwoLetterCountryCode.KN),
643
644
645
646
647 KOR("KOR", TwoLetterCountryCode.KR),
648
649
650
651
652 KWT("KWT", TwoLetterCountryCode.KW),
653
654
655
656
657 LAO("LAO", TwoLetterCountryCode.LA),
658
659
660
661
662 LBN("LBN", TwoLetterCountryCode.LB),
663
664
665
666
667 LBR("LBR", TwoLetterCountryCode.LR),
668
669
670
671
672 LBY("LBY", TwoLetterCountryCode.LY),
673
674
675
676
677 LCA("LCA", TwoLetterCountryCode.LC),
678
679
680
681
682 LIE("LIE", TwoLetterCountryCode.LI),
683
684
685
686
687 LKA("LKA", TwoLetterCountryCode.LK),
688
689
690
691
692 LSO("LSO", TwoLetterCountryCode.LS),
693
694
695
696
697 LTU("LTU", TwoLetterCountryCode.LT),
698
699
700
701
702 LUX("LUX", TwoLetterCountryCode.LU),
703
704
705
706
707 LVA("LVA", TwoLetterCountryCode.LV),
708
709
710
711
712 MAC("MAC", TwoLetterCountryCode.MO),
713
714
715
716
717 MAF("MAF", TwoLetterCountryCode.MF),
718
719
720
721
722 MAR("MAR", TwoLetterCountryCode.MA),
723
724
725
726
727 MCO("MCO", TwoLetterCountryCode.MC),
728
729
730
731
732 MDA("MDA", TwoLetterCountryCode.MD),
733
734
735
736
737 MDG("MDG", TwoLetterCountryCode.MG),
738
739
740
741
742 MDV("MDV", TwoLetterCountryCode.MV),
743
744
745
746
747 MEX("MEX", TwoLetterCountryCode.MX),
748
749
750
751
752 MHL("MHL", TwoLetterCountryCode.MH),
753
754
755
756
757 MKD("MKD", TwoLetterCountryCode.MK),
758
759
760
761
762 MLI("MLI", TwoLetterCountryCode.ML),
763
764
765
766
767 MLT("MLT", TwoLetterCountryCode.MT),
768
769
770
771
772 MMR("MMR", TwoLetterCountryCode.MM),
773
774
775
776
777 MNE("MNE", TwoLetterCountryCode.ME),
778
779
780
781
782 MNG("MNG", TwoLetterCountryCode.MN),
783
784
785
786
787 MNP("MNP", TwoLetterCountryCode.MP),
788
789
790
791
792 MOZ("MOZ", TwoLetterCountryCode.MZ),
793
794
795
796
797 MRT("MRT", TwoLetterCountryCode.MR),
798
799
800
801
802 MSR("MSR", TwoLetterCountryCode.MS),
803
804
805
806
807 MTQ("MTQ", TwoLetterCountryCode.MQ),
808
809
810
811
812 MUS("MUS", TwoLetterCountryCode.MU),
813
814
815
816
817 MWI("MWI", TwoLetterCountryCode.MW),
818
819
820
821
822 MYS("MYS", TwoLetterCountryCode.MY),
823
824
825
826
827 MYT("MYT", TwoLetterCountryCode.YT),
828
829
830
831
832 NAM("NAM", TwoLetterCountryCode.NA),
833
834
835
836
837 NCL("NCL", TwoLetterCountryCode.NC),
838
839
840
841
842 NER("NER", TwoLetterCountryCode.NE),
843
844
845
846
847 NFK("NFK", TwoLetterCountryCode.NF),
848
849
850
851
852 NGA("NGA", TwoLetterCountryCode.NG),
853
854
855
856
857 NIC("NIC", TwoLetterCountryCode.NI),
858
859
860
861
862 NIU("NIU", TwoLetterCountryCode.NU),
863
864
865
866
867 NLD("NLD", TwoLetterCountryCode.NL),
868
869
870
871
872 NOR("NOR", TwoLetterCountryCode.NO),
873
874
875
876
877 NPL("NPL", TwoLetterCountryCode.NP),
878
879
880
881
882 NRU("NRU", TwoLetterCountryCode.NR),
883
884
885
886
887 NZL("NZL", TwoLetterCountryCode.NZ),
888
889
890
891
892 OMN("OMN", TwoLetterCountryCode.OM),
893
894
895
896
897 PAK("PAK", TwoLetterCountryCode.PK),
898
899
900
901
902 PAN("PAN", TwoLetterCountryCode.PA),
903
904
905
906
907 PCN("PCN", TwoLetterCountryCode.PN),
908
909
910
911
912 PER("PER", TwoLetterCountryCode.PE),
913
914
915
916
917 PHL("PHL", TwoLetterCountryCode.PH),
918
919
920
921
922 PLW("PLW", TwoLetterCountryCode.PW),
923
924
925
926
927 PNG("PNG", TwoLetterCountryCode.PG),
928
929
930
931
932 POL("POL", TwoLetterCountryCode.PL),
933
934
935
936
937 PRI("PRI", TwoLetterCountryCode.PR),
938
939
940
941
942 PRK("PRK", TwoLetterCountryCode.KP),
943
944
945
946
947 PRT("PRT", TwoLetterCountryCode.PT),
948
949
950
951
952 PRY("PRY", TwoLetterCountryCode.PY),
953
954
955
956
957 PSE("PSE", TwoLetterCountryCode.PS),
958
959
960
961
962 PYF("PYF", TwoLetterCountryCode.PF),
963
964
965
966
967 QAT("QAT", TwoLetterCountryCode.QA),
968
969
970
971
972 REU("REU", TwoLetterCountryCode.RE),
973
974
975
976
977 ROU("ROU", TwoLetterCountryCode.RO),
978
979
980
981
982 RUS("RUS", TwoLetterCountryCode.RU),
983
984
985
986
987 RWA("RWA", TwoLetterCountryCode.RW),
988
989
990
991
992 SAU("SAU", TwoLetterCountryCode.SA),
993
994
995
996
997 SDN("SDN", TwoLetterCountryCode.SD),
998
999
1000
1001
1002 SEN("SEN", TwoLetterCountryCode.SN),
1003
1004
1005
1006
1007 SGP("SGP", TwoLetterCountryCode.SG),
1008
1009
1010
1011
1012 SGS("SGS", TwoLetterCountryCode.GS),
1013
1014
1015
1016
1017 SHN("SHN", TwoLetterCountryCode.SH),
1018
1019
1020
1021
1022 SJM("SJM", TwoLetterCountryCode.SJ),
1023
1024
1025
1026
1027 SLB("SLB", TwoLetterCountryCode.SB),
1028
1029
1030
1031
1032 SLE("SLE", TwoLetterCountryCode.SL),
1033
1034
1035
1036
1037 SLV("SLV", TwoLetterCountryCode.SV),
1038
1039
1040
1041
1042 SMR("SMR", TwoLetterCountryCode.SM),
1043
1044
1045
1046
1047 SOM("SOM", TwoLetterCountryCode.SO),
1048
1049
1050
1051
1052 SPM("SPM", TwoLetterCountryCode.PM),
1053
1054
1055
1056
1057 SRB("SRB", TwoLetterCountryCode.RS),
1058
1059
1060
1061
1062 SSD("SSD", TwoLetterCountryCode.SS),
1063
1064
1065
1066
1067 STP("STP", TwoLetterCountryCode.ST),
1068
1069
1070
1071
1072 SUR("SUR", TwoLetterCountryCode.SR),
1073
1074
1075
1076
1077 SVK("SVK", TwoLetterCountryCode.SK),
1078
1079
1080
1081
1082 SVN("SVN", TwoLetterCountryCode.SI),
1083
1084
1085
1086
1087 SWE("SWE", TwoLetterCountryCode.SE),
1088
1089
1090
1091
1092 SWZ("SWZ", TwoLetterCountryCode.SZ),
1093
1094
1095
1096
1097 SXM("SXM", TwoLetterCountryCode.SX),
1098
1099
1100
1101
1102 SYC("SYC", TwoLetterCountryCode.SC),
1103
1104
1105
1106
1107 SYR("SYR", TwoLetterCountryCode.SY),
1108
1109
1110
1111
1112 TCA("TCA", TwoLetterCountryCode.TC),
1113
1114
1115
1116
1117 TCD("TCD", TwoLetterCountryCode.TD),
1118
1119
1120
1121
1122 TGO("TGO", TwoLetterCountryCode.TG),
1123
1124
1125
1126
1127 THA("THA", TwoLetterCountryCode.TH),
1128
1129
1130
1131
1132 TJK("TJK", TwoLetterCountryCode.TJ),
1133
1134
1135
1136
1137 TKL("TKL", TwoLetterCountryCode.TK),
1138
1139
1140
1141
1142 TKM("TKM", TwoLetterCountryCode.TM),
1143
1144
1145
1146
1147 TLS("TLS", TwoLetterCountryCode.TL),
1148
1149
1150
1151
1152 TON("TON", TwoLetterCountryCode.TO),
1153
1154
1155
1156
1157 TTO("TTO", TwoLetterCountryCode.TT),
1158
1159
1160
1161
1162 TUN("TUN", TwoLetterCountryCode.TN),
1163
1164
1165
1166
1167 TUR("TUR", TwoLetterCountryCode.TR),
1168
1169
1170
1171
1172 TUV("TUV", TwoLetterCountryCode.TV),
1173
1174
1175
1176
1177 TWN("TWN", TwoLetterCountryCode.TW),
1178
1179
1180
1181
1182 TZA("TZA", TwoLetterCountryCode.TZ),
1183
1184
1185
1186
1187 UGA("UGA", TwoLetterCountryCode.UG),
1188
1189
1190
1191
1192 UKR("UKR", TwoLetterCountryCode.UA),
1193
1194
1195
1196
1197 UMI("UMI", TwoLetterCountryCode.UM),
1198
1199
1200
1201
1202 URY("URY", TwoLetterCountryCode.UY),
1203
1204
1205
1206
1207 USA("USA", TwoLetterCountryCode.US),
1208
1209
1210
1211
1212 UZB("UZB", TwoLetterCountryCode.UZ),
1213
1214
1215
1216
1217 VAT("VAT", TwoLetterCountryCode.VA),
1218
1219
1220
1221
1222 VCT("VCT", TwoLetterCountryCode.VC),
1223
1224
1225
1226
1227 VEN("VEN", TwoLetterCountryCode.VE),
1228
1229
1230
1231
1232 VGB("VGB", TwoLetterCountryCode.VG),
1233
1234
1235
1236
1237 VIR("VIR", TwoLetterCountryCode.VI),
1238
1239
1240
1241
1242 VNM("VNM", TwoLetterCountryCode.VN),
1243
1244
1245
1246
1247 VUT("VUT", TwoLetterCountryCode.VU),
1248
1249
1250
1251
1252 WLF("WLF", TwoLetterCountryCode.WF),
1253
1254
1255
1256
1257 WSM("WSM", TwoLetterCountryCode.WS),
1258
1259
1260
1261
1262 YEM("YEM", TwoLetterCountryCode.YE),
1263
1264
1265
1266
1267 ZAF("ZAF", TwoLetterCountryCode.ZA),
1268
1269
1270
1271
1272 ZMB("ZMB", TwoLetterCountryCode.ZM),
1273
1274
1275
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
1290
1291
1292
1293 public TwoLetterCountryCode getTwoLetterCountryCode() {
1294 return twoLetterCountryCode;
1295 }
1296
1297
1298
1299
1300
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
1314
1315
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
1343
1344
1345
1346
1347 @JsonCreator
1348 public static ThreeLetterCountryCode fromValue(final String text) {
1349 return fromValue(text, null);
1350 }
1351
1352
1353
1354
1355
1356
1357
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
1382
1383
1384
1385
1386 public static ThreeLetterCountryCode fromLocale(final Locale locale) {
1387 return fromLocale(locale, null);
1388 }
1389
1390
1391
1392
1393
1394
1395
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