291 Commits

Author SHA1 Message Date
Alejandro Matos a3d76db7d7 fix #287: normalizing open street maps url 2026-02-24 17:35:24 -05:00
Alejandro Matos 1993aa6a65 fixing json format 2026-02-24 17:26:09 -05:00
Alejandro Matos d139284376 WIP #286: adding missing fields 2026-02-24 17:20:20 -05:00
Alejandro Matos 5841613ae0 Merge branch 'v4' into 'master'
Finnishing V4 as Preview

See merge request restcountries/restcountries!105
2026-02-20 19:12:08 +00:00
Alejandro Matos 8b2111c8e1 Finnishing V4 as Preview 2026-02-20 19:12:07 +00:00
Alejandro Matos 49bf6e26b5 Merge branch 'patch-4' into 'master'
A couple flag description corrections

See merge request restcountries/restcountries!104
2026-02-14 05:37:16 +00:00
Alec Mitnik cee84c84e5 A couple flag description corrections
* Fixed capitalization of Zimbabwe Bird
* Added description of Costa Rica coat of arms, which wasn't mentioned.  The original description was for the version without the coat of arms, but the image used is for the one with the coat of arms.
2026-02-14 05:35:12 +00:00
Alejandro Matos 4d0c0f6d5f Merge branch 'patch-3' into 'master'
#274 - Added missing flag descriptions

See merge request restcountries/restcountries!103
2026-02-14 04:57:27 +00:00
Alec Mitnik 883940e36b Added period to Jamaica flag description for consistency 2026-02-14 04:54:17 +00:00
Alec Mitnik c2c74db463 #274 - Added missing flag descriptions
Descriptions are derived from the CIA World Factbook or Wikipedia.
2026-02-14 04:36:07 +00:00
Alejandro Matos 423251208c Closes #271: fix Ivory Cost's translation into Slovak 2026-02-13 13:05:59 -05:00
Alejandro Matos 32b937341b Closes #280: error message when sending more than 10 fields should be more specific 2026-02-13 12:56:21 -05:00
Alejandro Matos ecd9e6c588 Closes #283: Paraguay has 6 digits postal code 2026-02-13 12:49:29 -05:00
Alejandro Matos 59c9383978 Merge branch 'patch-2' into 'master'
#284 - The euro currency shouldn't be capitalized

See merge request restcountries/restcountries!102
2026-02-11 14:50:12 +00:00
Alec Mitnik 90a8fff6f5 #284 - The euro currency shouldn't be capitalized
Changed all entries for the euro currency to be lowercase, consistent with other currencies.
2026-02-11 07:17:38 +00:00
Alejandro Matos db5a085a93 Merge branch 'master' into 'master'
update Indonesian translation for some countries

See merge request restcountries/restcountries!101
2026-01-28 23:20:07 +00:00
Alejandro Matos 97d02fde04 Merge branch 'master' into 'master'
Removed # from before Demonym that was making it not the same size as the other secondary headers.

See merge request restcountries/restcountries!99
2026-01-28 19:47:46 +00:00
Alejandro Matos 3ebefc002e renaming java docker image 2026-01-28 14:29:46 -05:00
Fathul Husnan e51c115631 update Indonesian translation for some countries 2026-01-20 13:30:34 +07:00
Alex DeStefano 5277a57f47 Removed # from before Demonym that was making it not the same size as the other secondary headers. 2025-12-05 18:20:17 +00:00
Alejandro Matos 1fda9163d5 Merge branch 'fatimarahmani-master-patch-17297-fix-afghanistan-language' into 'master'
Add Dari Persian as an official language of Afghanistan

See merge request restcountries/restcountries!98
2025-11-12 16:14:51 +00:00
Fatima Rahmani 47e5447de9 Edit countriesV2.json.
Added missing official language 'Dari Persian' to Afghanistan dataset
2025-11-12 06:56:57 +00:00
Alejandro Matos d815c26ab2 Merge branch 'alec-mitnik-master-patch-10118' into 'master'
#276 - Updated area and population data for consistency

See merge request restcountries/restcountries!96
2025-10-31 04:32:17 +00:00
Alec Mitnik 261e7e3a0b #276 - Updated area and population data for consistency 2025-10-30 11:57:17 +00:00
Alejandro Matos c5a2e71b66 Merge branch 'fix/bouvet-island-latitude' into 'master'
Fix Bouvet Island latitude (should be negative)

See merge request restcountries/restcountries!95
2025-10-30 01:18:22 +00:00
mg2k4 8f04e59ae1 Fix Bouvet Island latitude (should be negative) 2025-10-30 00:23:41 +00:00
Alejandro Matos 9b8d08c120 Merge branch 'alec-mitnik-master-patch-12852' into 'master'
#276 - Updated population data

See merge request restcountries/restcountries!94
2025-10-29 03:13:18 +00:00
Alec Mitnik c1bf20eff1 #276 - Updated population data 2025-10-28 12:37:42 +00:00
Alejandro Matos 227da47d2a Merge branch 'alec-mitnik-master-patch-63721' into 'master'
Flag alt description edits

See merge request restcountries/restcountries!93
2025-10-26 19:49:51 +00:00
Alec Mitnik 46e82a9334 Flag alt description edits
Removed erroneous description for São Tomé and Príncipe (#274).
Added missing "the" for Croatia description.
2025-10-25 13:56:11 +00:00
Alejandro Matos fe6275fd91 Merge branch 'patch-1' into 'master'
#275 - Removed India as a bordering country from Sri Lanka

See merge request restcountries/restcountries!92
2025-09-29 15:46:15 +00:00
Alec Mitnik ce78e0e33c #275 - Removed India as a bordering country from Sri Lanka 2025-09-29 03:16:10 +00:00
Alejandro Matos 3ef0d593f5 Merge branch 'patch-2' into 'master'
Corrected the Korean expression for "Wallis and Futuna"

See merge request restcountries/restcountries!91
2025-07-18 01:58:56 +00:00
Alejandro Matos 793f7c477a Merge branch 'molajusi-master-patch-45b8' into 'master'
Corrected: The Korean expressions

See merge request restcountries/restcountries!90
2025-07-17 14:05:44 +00:00
molajusi ne a1e5339c01 Corrected the Korean expression for "Wallis and Futuna" 2025-07-15 07:05:51 +00:00
molajusi ne e2716064ea Corrected: The Korean expression for "Commonwealth of Dominica", "Mongolia" and "South Africa". 2025-07-15 02:24:40 +00:00
Alejandro Matos 65e996dece Merge branch 'patch-1' into 'master'
Corrected the Korean expression for "British Indian Ocean Territory".

See merge request restcountries/restcountries!89
2025-07-07 14:34:54 +00:00
molajusi ne 7dfe4ed534 Corrected:
The Korean expression for "British Indian Ocean Territory".
2025-07-07 07:11:41 +00:00
Alejandro fd6c6834dd Updated #256: avoids 200 when fields are empty 2025-06-05 12:51:08 -05:00
Alejandro 3e9f6d6bd6 Closes #255: adding Yusif's project to docs 2025-06-05 09:43:42 -05:00
Alejandro Matos 6ca8666a2d Merge branch 'feature/all-endpoints-require-fields' into 'master'
#265 endpoint 'all' requires fields to be specified

See merge request restcountries/restcountries!88
2025-06-05 14:13:25 +00:00
Alejandro 7378efe122 #265 endpoint 'all' requires fields to be specified 2025-06-04 17:12:47 -05:00
Alejandro 8c264c0a6c revert for 5 days: endpoint all must specify the fields 2025-06-04 17:05:33 -05:00
Alejandro 5e1ac7624e endpoint all must specify the fields 2025-06-04 11:17:59 -05:00
Alejandro Matos 952b37e00e Merge branch 'fix/belgium-turkish-translation' into 'master'
belgium - turkish translation fixed

See merge request restcountries/restcountries!87
2025-05-29 22:41:49 +00:00
ozan 09f18cb17c translation fixed (belğika -> belçika) 2025-05-27 22:23:57 +00:00
Alejandro 47ad02fa78 Closes #262: capital of Indonesia is Jakarta 2025-05-13 09:47:09 -05:00
Alejandro Matos 389e992459 Merge branch 'remove-empty-currencies-and-fix-alt-field' into 'master'
Remove empty alt field of coatOfArms and fix currencies

See merge request restcountries/restcountries!86
2025-04-22 15:23:04 +00:00
Yusif Aliyev a28550fa02 Update currencies field from array to object in countries JSON files and fix empty alt field in coatOfArms for Grenada and Christhmas Island 2025-04-22 19:12:56 +04:00
Alejandro 40e21ae949 fixing 502 2025-04-21 09:26:13 -05:00
Alejandro d36e2a8605 Closes #208
Changing independence status of Kosovo
2025-04-20 19:34:12 -05:00
Alejandro e94bf89ba3 Closes # 237
wrong oficial name for Portugal
2025-04-20 19:25:07 -05:00
Alejandro 72b77288cf Closes #241
Assigning the correct coat of arms to the correct country
2025-04-20 19:23:01 -05:00
Alejandro a646d4d5b0 Closes #243
changing Kazakhstan's capital
2025-04-20 19:18:50 -05:00
Alejandro 0d86f1ce03 closes #244
start of week also includes saturday
2025-04-20 19:17:15 -05:00
Alejandro 10a3263673 closes #247
Brasil's week starts on Sunday
2025-04-20 19:13:04 -05:00
Alejandro Matos 5435650866 Merge branch 'update/java-wrapper-link' into 'master'
added restcountries Java Wrapper link

See merge request restcountries/restcountries!74
2025-04-21 00:07:29 +00:00
Alejandro Matos 8524f480f2 Merge branch 'master' into 'master'
Add Catalan to Italy as language for Alguer (Sardenya).

See merge request restcountries/restcountries!71
2025-04-21 00:06:29 +00:00
Alejandro Matos 77cb7de959 Merge branch 'fathulhusnan-master-patch-79646' into 'master'
Add Indonesian translation for country name

See merge request restcountries/restcountries!76
2025-04-21 00:04:07 +00:00
Alejandro Matos 70224421d0 Merge branch 'feature/adjust-latlng-for-some-countries' into 'master'
Adjust latitude and longitude for some countries

See merge request restcountries/restcountries!78
2025-04-20 23:59:40 +00:00
Alejandro Matos b3ff22a100 Merge branch 'master' into 'master'
MOD : SGS currency is the pound

See merge request restcountries/restcountries!79
2025-04-20 23:58:43 +00:00
Alejandro Matos 767a2be9bd Merge branch 'feat/add_php_package' into 'master'
adds php restcountries package

See merge request restcountries/restcountries!80
2025-04-20 23:57:08 +00:00
Alejandro Matos 5b2b9f72ac Merge branch 'master' into 'master'
Added 658 prefix code to Jamaica

See merge request restcountries/restcountries!82
2025-04-20 23:56:07 +00:00
Alejandro Matos 23dbc90165 Merge branch 'master' into 'master'
Correct german language code

See merge request restcountries/restcountries!83
2025-04-20 23:55:40 +00:00
Alejandro 035f132ade closes #251
updating Sierra Leone currency
2025-04-20 18:51:15 -05:00
Alejandro Matos 67bf122161 Edit .gitlab-ci.yml 2025-04-20 23:35:44 +00:00
Alejandro Matos 18f2883968 Edit .gitlab-ci.yml 2025-04-20 23:29:28 +00:00
Alejandro Matos 087c783463 fixing Dockerfile 2025-04-20 23:14:22 +00:00
Alejandro Matos ccdfe20876 Merge branch 'main' into 'master'
Main

See merge request restcountries/restcountries!84
2025-04-20 23:06:19 +00:00
Alejandro Matos 55177a1a13 Main 2025-04-20 23:06:19 +00:00
Ryszard Urbanek 83a3c1a7d6 Correct german language code 2025-02-17 18:36:42 +00:00
Luca Romeo 817d0018e5 Added 658 prefix code to Jamaica 2025-02-14 16:09:09 +00:00
Hamed Haghi 366381015b adds php restcountries package 2025-01-07 12:54:51 +00:00
rvergnory 688a6e9fe5 MOD : SGS currency is the pound 2025-01-07 09:44:38 +01:00
Alejandro Matos b9170a3ced Merge branch 'AntonioCalheirosNeves-master-patch-77975' into 'master'
Changed official name for Portugal

See merge request restcountries/restcountries!77
2024-12-11 22:48:19 +00:00
beauchama c341b1e5ff Updated latlng 2024-11-30 09:20:56 -05:00
Antonio Neves 1f969a97b1 Changed official name for Portugal 2024-11-29 09:19:54 +00:00
Fathul Husnan f9dd67cbf6 Add Indonesian translation for country name 2024-11-25 16:34:22 +00:00
Alejandro Matos 306352c2c9 Merge branch 'Neg4tive-master-patch-40529' into 'master'
Change the capital of indonesia for Nusantara

See merge request restcountries/restcountries!75
2024-11-07 15:02:22 +00:00
Thomas Pouget de69f8b9cc Update countriesV3.1.json change the capital of indonesia for Nusantara the new capital since 17/08/2024 2024-10-23 08:16:51 +00:00
Awais Rashid 0b1c25de8e added restcountries Java Wrapper link 2024-09-05 17:27:21 +05:00
Alejandro Matos 1784e5cbf1 Merge remote-tracking branch 'refs/remotes/origin/master' 2024-08-26 10:20:39 -05:00
Alejandro Matos 71bd3cc230 closes #233 fixing typo 2024-08-26 10:04:10 -05:00
Alejandro Matos f2e3e31e80 Merge branch 'pwalkowski-master-patch-61485' into 'master'
Update countriesV3.1.json - currency symbols for Bosnia & Hercegovina and Sudan

See merge request restcountries/restcountries!73
2024-07-17 00:35:18 +00:00
pwalkowski 6acdb0aa92 Update countriesV3.1.json - currency symbols for Bosnia & Hercegovina and Sudan 2024-07-16 11:06:42 +00:00
Alejandro Matos e67beb4421 removing rate limiting 2024-06-11 17:45:15 -05:00
Alejandro Matos 21ddaeff41 removing rate limiting 2024-06-11 17:35:50 -05:00
Alejandro Matos aac0ff5f91 Merge branch 'Mohamed-H-A-master-patch-22739' into 'master'
Change Vatican city 'unMember' field to 'false', fix Cape Verde coordinates

See merge request restcountries/restcountries!70
2024-04-14 18:07:01 +00:00
pataquets 65b879eeff Add Catalan to Italy as language for Alguer (Sardenya). 2024-04-14 01:21:13 +02:00
Mohamed-H-A d65710c3f7 Update countriesV3.1.json 2024-04-13 20:06:32 +00:00
Alejandro Matos 6a9678f8be Update Default.md 2024-04-12 06:00:12 +00:00
Alejandro Matos 9d3916cb49 Delete issues.md 2024-04-12 05:59:21 +00:00
Alejandro Matos dbb7caac78 Update Default.md 2024-04-11 20:26:48 +00:00
Alejandro Matos 377a98cd49 Add new file 2024-04-11 20:25:31 +00:00
Alejandro Matos d1154f3a1c Update issues.md 2024-04-11 20:22:52 +00:00
Alejandro Matos be04c41c88 issue template 2024-04-11 20:19:07 +00:00
Alejandro Matos 9ad00c75e9 Add new directory 2024-04-11 20:15:25 +00:00
Alejandro Matos 8ed5625d94 Merge branch 'master' of gitlab.com:restcountries/restcountries 2024-01-14 17:08:21 -05:00
Alejandro Matos ee498c74ad Closes #219: correcting Svalbard and Jan Mayen area 2024-01-14 17:02:20 -05:00
Alejandro Matos bc15c46c2f Merge branch 'crimento-master-patch-90002' into 'master'
Reordering Singapore languages

See merge request restcountries/restcountries!69
2023-11-25 03:39:54 +00:00
Александр Абраменко 38e97f44c1 Singapore English is now primary speaking language of Singapore as of 2020
https://en.wikipedia.org/wiki/Languages_of_Singapore#English_as_the_main_language_of_Singapore
https://www.singstat.gov.sg/-/media/files/publications/cop2020/sr1/cop2020sr1.pdf
2023-11-24 18:05:14 +00:00
Alejandro Matos faaed1b971 Merge branch 'fix/update_spanish_languages' into 'master'
Update Spanish languages.

See merge request restcountries/restcountries!68
2023-11-15 22:08:39 +00:00
Miguel Gisbert 8ac63ce707 Update Spanish languages. 2023-11-15 22:32:51 +01:00
Alejandro Matos da9c798b7f Merge branch 'master' into 'master'
Add "658" as "callingCodes / idd" for Jamaica

See merge request restcountries/restcountries!67
2023-10-20 17:41:17 +00:00
Danilo 5265ba86c6 Add "658" as "callingCodes / idd" for Jamaica, as informed https://nationalnanpa.com/pdf/PL_525.pdf 2023-10-20 14:48:54 +00:00
Alejandro Matos 8026f6d736 Closes #207 2023-09-20 14:47:59 +00:00
Alejandro Matos ada356dc8c Closes #205 2023-09-12 18:06:40 +00:00
Alejandro Matos 1a0c03c4e3 Merge branch 'fix_NLD_timezone' into 'master'
The timezone for the Netherlands is only UTC+01:00.

See merge request restcountries/restcountries!66
2023-08-30 21:25:14 +00:00
Marc Nguyen Marc 8464f315ec The timezone for the Netherland is only UTC+01:00, the timezone UTC-04:00 belongs to common: Caribbean Netherlands. 2023-08-18 10:18:41 +02:00
Alejandro Matos eb6424a0db Merge branch 'javidan_amiraliyev-master-patch-33654' into 'master'
Removed the Russian language info from Azerbaijan. Added Europe continent to Azerbaijan.

See merge request restcountries/restcountries!65
2023-08-16 20:05:53 +00:00
Javidan Amiraliyev 8342be9bdf Removed the Russian language info from Azerbaijan. Added Europe continent to Azerbaijan. 2023-08-11 11:52:22 +00:00
Alejandro Matos 6c8773d398 closes #203: adding link to FIELDS.md file 2023-08-04 16:37:14 -05:00
Alejandro Matos 45f99e36f3 Merge branch 'master' into 'master'
Additional Continents: Europe for Turkey and Asia for Russian Federation

See merge request restcountries/restcountries!62
2023-08-04 06:10:20 +00:00
Alejandro Matos b51e696283 Merge branch 'demonym-doc-typo-fix' into 'master'
Fix heading level for Demonym docs so they aren't under Currency

See merge request restcountries/restcountries!63
2023-08-04 06:04:42 +00:00
Alex Cochran ce0d43a982 Fix heading level for Demonym docs so they aren't under Currency 2023-08-02 10:59:05 -06:00
michael.frank 1123a6dea8 Additional Continents: Europe for Turkey and Asia for Russian Federation 2023-07-12 12:58:12 +02:00
Alejandro Matos 3afb1f7dcb Updating docs 2023-05-24 18:34:54 +00:00
Alejandro Matos 3deb53df5f Fixes #191: wrong latlong for some countries 2023-05-16 09:02:32 -05:00
Alejandro Matos aab349e06a FIX: trying to fix docker login 2023-05-15 21:21:17 -05:00
Alejandro Matos 5de2255fff Closes #195: fixing Canada's postal code regex thanks to FFGFlash 2023-05-15 21:09:09 -05:00
Alejandro Matos 22341d6efb Fixing an issue with the Application class 2023-05-04 10:50:50 -05:00
Alejandro Matos e167961a22 Updating message to reflect what's in #194 2023-05-04 10:48:23 -05:00
Alejandro Matos c707b2d885 Merge branch 'master' into 'master'
provide absolute URL in servers

See merge request restcountries/restcountries!61
2023-03-27 16:52:27 +00:00
Muhammad Aaqil eb76b72e52 provide absolute URL in servers 2023-03-27 16:52:27 +00:00
Alejandro Matos 7b0a4f2a21 Merge branch 'master' into 'master'
Fix typo in fra translation for Antigua and Barbuda

See merge request restcountries/restcountries!60
2023-03-17 15:12:11 +00:00
ShevAbam 74ad597513 Fix typo in fra translation for Antigua and Barbuda 2023-03-14 09:17:27 +01:00
Alejandro Matos 59ea26d423 Updating the public readme 2023-03-13 23:13:34 -05:00
Alejandro Matos e202435cc3 Trying to publish latest changes 2023-03-12 20:13:06 -05:00
Alejandro Matos 341f0fdb69 Merge branch 'feature/v4' 2023-03-10 13:26:55 -05:00
Alejandro Matos 5c19f17c13 Closes #186 #189:
* fixing Austrian language field
* adding 'independent' endpoint to get only independent countries
2023-03-10 13:22:34 -05:00
Alejandro Matos c42fe46ea2 Updating issue link 2023-03-02 18:03:26 +00:00
Alejandro Matos 64d7de12e1 Adding code of conduct 2023-03-02 17:41:38 +00:00
Alejandro Matos 78c44ffc60 Updating the readme file 2023-03-02 05:56:17 +00:00
Alejandro Matos 6071113b4a Merge branch 'serbian-language' into 'master'
add serbian language country names

See merge request amatos/rest-countries!59
2023-02-02 22:10:50 +00:00
Ivan Sarajčić 857efa988d add serbian language country names 2023-01-31 12:51:05 +01:00
Alejandro Matos ac870ef548 Merge branch 'feature/v4' into 'master'
Adding implementation for alt images

See merge request amatos/rest-countries!58
2023-01-30 17:23:07 +00:00
Alejandro Matos 01aed3f4c7 missing alt properties 2023-01-30 12:19:45 -05:00
Alejandro Matos adc935a761 Adding implementation for alt images 2023-01-30 12:02:44 -05:00
Alejandro Matos 2b4dac3e97 Merge branch 'flag-descriptions-for-independent-nations' into 'master'
Added a description of the flags of all 194 independent countries in the API

See merge request amatos/rest-countries!57
2023-01-30 16:43:53 +00:00
Praise Agbabiaka 1f6b12de22 Added a description of the flags of all 194 independent countries in the API 2023-01-30 16:43:53 +00:00
Alejandro Matos 0ae03045eb Merge branch 'fix-croatian-currency' into 'master'
Change Croatian currency to euro

See merge request amatos/rest-countries!56
2023-01-07 11:33:35 +00:00
Mladen Macanovic 4a609d373f Change Croatian currency to euro 2023-01-07 11:33:35 +00:00
Alejandro Matos 718248f4ad Merge branch 'CharlieYu1-master-patch-56949' into 'master'
Update countriesV3.1.json for the correct latlng for Hong Kong

See merge request amatos/rest-countries!55
2023-01-06 02:16:32 +00:00
CharlieYu1 4647daf01c Update countriesV3.1.json 2023-01-03 03:05:41 +00:00
Alejandro Matos acaf61f74a Merge remote-tracking branch 'origin/master' 2022-12-23 00:00:04 -05:00
Alejandro Matos 043b9ab87d Fixes #178: Brunei and Bahrain sharing the same BRN is a no no. 2022-12-22 23:59:40 -05:00
Alejandro Matos 2c30416c8f Merge branch 'heychazza-master-patch-73977' into 'master'
Fix lat and long coords

See merge request amatos/rest-countries!54
2022-11-10 03:25:30 +00:00
Charlie Joseph 9cec59e652 Fix lat and long coords 2022-10-27 18:14:10 +00:00
Alejandro Matos bc65bb03dc Fixes #157: adding HTTP Caching (plus some minor fixes) 2022-10-27 00:33:24 -05:00
Alejandro Matos d488a8ad64 Merge branch 'lubomirkurcak-master-patch-02580' into 'master'
common names for united arab emirates

See merge request amatos/rest-countries!53
2022-10-17 15:18:04 +00:00
Alejandro Matos ce9b97bae5 Merge branch 'lubomirkurcak-master-patch-92551' into 'master'
common name for North Korea in slovak

See merge request amatos/rest-countries!52
2022-10-17 15:17:39 +00:00
Alejandro Matos ccc5a2ce02 Merge branch 'lubomirkurcak-master-patch-10830' into 'master'
south africa common names for spa, slk, hrv, rus.

See merge request amatos/rest-countries!51
2022-10-17 15:17:26 +00:00
Lubomir 0bf7e53dc2 common names for united arab emirates 2022-10-13 16:24:53 +00:00
Lubomir 5dba603e50 common name for North Korea in slovak 2022-10-12 21:56:24 +00:00
Lubomir 7138b2af97 south africa common names for spa, slk, hrv, rus. 2022-10-12 17:40:08 +00:00
Alejandro Matos c502592192 Closes #161: fixing start of the week for Iran 2022-10-01 16:37:31 -05:00
Alejandro Matos 9cf493cf62 Fixes #162: maps were switched. Now fixed 2022-10-01 16:35:18 -05:00
Alejandro Matos 4703f5c8dc Closes #154: adding Jerusalem as Capital for Palestine 2022-09-29 21:02:49 -05:00
Alejandro Matos 3868264a7f Merge remote-tracking branch 'origin/master' 2022-09-29 20:51:46 -05:00
Alejandro Matos 4a5da1f40e Fixes #159 changing Georgia's time zone to +4 2022-09-29 20:50:42 -05:00
Alejandro Matos 07af6e3908 Merge branch 'master' into 'master'
M - Moldova Language Fix

See merge request amatos/rest-countries!50
2022-09-22 02:07:12 +00:00
Alex b5834e3673 Merge branch 'alexanderchilari-master-patch-49674' into 'master'
MOLDOVA UPDATE

See merge request alexanderchilari/rest-countries-moldova-fix!1
2022-09-17 14:03:25 +00:00
Alex c47296df7e MOLDOVA UPDATE 2022-09-17 14:01:12 +00:00
Alejandro Matos 666492a60f Merge branch 'ubeydeozdmr-master-patch-04566' into 'master'
Added Turkish language to translations

See merge request amatos/rest-countries!48
2022-09-17 04:32:51 +00:00
Ubeyde Emir Özdemir a61c7bced2 Added Turkish language to translations 2022-09-15 22:57:18 +00:00
Alejandro Matos 7a111655df Merge branch 'add-breton' into 'master'
Add breton (br / bre) country translations, fix v2

See merge request amatos/rest-countries!47
2022-08-25 03:15:29 +00:00
Alexis Launay 62c2d79b13 Fix V2 test 2022-08-24 23:28:35 +02:00
Alexis Launay 68372cb453 Add breton (br / bre) country translations, fix v2 2022-08-24 22:23:26 +02:00
Alejandro Matos d9a4b2d88b Closes #144: fixing missing Kazakhstan's independence 2022-08-02 23:00:58 +00:00
Alejandro Matos 8a1d3da6e8 Closes #146: fixing a typo in UK
the Polish translation for United Kingdom had a typo in the common name.
2022-08-02 22:47:29 +00:00
Alejandro Matos c6c83086c8 Merge branch 'master' into 'master'
Adds missing value for South Sudan CIOC field

See merge request amatos/rest-countries!46
2022-07-19 03:20:15 +00:00
John Coppola 27ff9a21d4 adds missing value for South Sudan CIOC field 2022-07-18 08:31:16 -07:00
Alejandro Matos 6cf8153de7 Fixes #135 #140: Fixing wrong documentation to reflect some changes 2022-07-07 22:06:29 -05:00
Alejandro Matos 5681387d9c Closes #138: Searching for an unknown country won't return an exception 2022-07-07 21:58:18 -05:00
Alejandro Matos 1ec9a0c785 Upgrading dependencies 2022-06-23 21:19:11 -05:00
Alejandro Matos 26610868b1 Fixes #122: Adding emoji flag for Caribbean Netherlands 2022-06-08 09:42:25 -05:00
Alejandro Matos 2c85d34658 Closes #127: updating population
DR Congo & Congo
2022-06-08 09:39:40 -05:00
Alejandro Matos 1e2946f126 Fixes #124: searching by name gives the correct result 2022-05-19 12:03:46 -05:00
Alejandro Matos fc50401adc Merge branch 'feature/add-openapi-spe' into 'master'
add micronaut openapi spec generation

See merge request amatos/rest-countries!43
2022-03-14 14:47:55 +00:00
Alejandro Matos a86a7adf8e Merge branch 'master' into 'feature/add-openapi-spe'
# Conflicts:
#   src/main/java/dev/amatos/restcountries/controller/CountryControllerV2.java
#   src/main/java/dev/amatos/restcountries/controller/CountryControllerV31.java
2022-03-14 14:47:35 +00:00
Alejandro Matos 89e1c43f5c Closes #117: Updating Algeria's population 2022-03-09 18:56:53 +00:00
Alejandro Matos 85d658a6ce Merge branch 'master' into 'master'
Added missing capital cities

See merge request amatos/rest-countries!44
2022-03-09 15:25:38 +00:00
Dre 6fe422e776 Revert 3 capital cities to empty array 2022-03-09 15:17:41 +00:00
Dre eaa157834b Added missing capital cities 2022-03-03 18:37:29 +00:00
Alejandro Matos 6e7f6a4355 Merge branch 'master' of gitlab.com:amatos/rest-countries 2022-02-22 01:04:22 -05:00
Alejandro Matos d348f184da Closes #85, #107, #114 and #115: Returning correct HTTP response statuses 2022-02-22 01:03:49 -05:00
Patrick Riegler fc0876c493 properly name openapi component schema 2022-02-18 14:44:19 +01:00
Patrick Riegler 591996e4bc remove micronaut openapi spec generation for previous versions and add / in front of controller paths to make the controller definition openapi compatible 2022-02-18 14:25:29 +01:00
Patrick Riegler 6da77ad073 define router to point to openapi spec yaml 2022-02-16 09:09:58 +01:00
Patrick Riegler 04af529616 add micronaut openapi spec generation 2022-02-15 17:52:01 +01:00
Alejandro Matos 44adb68c5b Upgrading log4J 2022-02-15 09:41:53 -05:00
Alejandro Matos a81aa3a8a4 Fixes #109: mistranslation of Cameroon in Polish 2022-02-07 12:57:35 -05:00
Alejandro Matos cb6e18520b Upgrade from 14 to 17 2022-02-05 13:00:12 -05:00
Alejandro Matos 3fd920648b Fixes #103: wrong currency symbol for Turkey 2022-01-31 10:53:49 -05:00
Alejandro Matos 2613a67d2f Merge branch 'stanley-t-chideme-master-patch-64764' into 'master'
Stanley t chideme master patch 64764

See merge request amatos/rest-countries!42
2022-01-27 20:10:28 +00:00
Stanley Chideme c8efcca409 zimbabwe sub Region to Southern Africa in all ver 2022-01-27 08:24:14 +00:00
Stanley Chideme db0e1f0309 Changed sub region of Zimbabwe to Southern Africa 2022-01-27 08:21:06 +00:00
Alejandro Matos a4fceb6230 Merge branch 'fix/#102' into 'master'
#102: fixed wrong timezones in all json resources

See merge request amatos/rest-countries!41
2022-01-14 15:48:34 +00:00
Boyan Stanchev 8a02cf44b7 #102: fixed wrong timezones in all json resources 2022-01-14 15:20:15 +02:00
Alejandro Matos 46ed2970fd Merge pull request #9 from amatosg/dependabot/maven/org.apache.logging.log4j-log4j-core-2.15.0
Bump log4j-core from 2.14.1 to 2.15.0
2022-01-11 12:46:21 -05:00
Alejandro Matos 4d1e8e4200 Merge branch 'ePascalC-master-patch-64800' into 'master'
Fixes #96 - East Timor wrong currency

Closes #96

See merge request amatos/rest-countries!40
2022-01-10 20:42:11 +00:00
Alejandro Matos 487aecf949 Merge branch 'ePascalC-master-patch-26417' into 'master'
Fixes issue #99

Closes #99

See merge request amatos/rest-countries!38
2022-01-10 20:33:23 +00:00
Pascal Casier 5bd4378e9e Update src/main/resources/countriesV3.1.json 2022-01-10 20:31:16 +00:00
Alejandro Matos 003b3ba66f Merge branch 'ePascalC-master-patch-68263' into 'master'
Fixes #95 : Singapore wrong currency

Closes #95

See merge request amatos/rest-countries!39
2022-01-10 20:13:36 +00:00
Pascal Casier 03e50c52c3 Fixes #96 - East Timor wrong currency 2022-01-10 19:55:13 +00:00
Pascal Casier 1080ab9849 Fixes #95
Error only found in V2
2022-01-10 19:48:25 +00:00
Pascal Casier e2c3cb5693 Fixes issue #99 2022-01-10 19:41:06 +00:00
Alejandro Matos 252157a62d Merge branch 'ePascalC-master-patch-59913' into 'master'
Update Switzerland Population

See merge request amatos/rest-countries!37
2021-12-31 15:22:49 +00:00
Pascal Casier 2be6e44c03 Update Switzerland Population
fix for #98
2021-12-31 15:19:03 +00:00
Alejandro Matos f2a826545a Merge branch '94-bad-hungarian-country-name-translations-in-countriesv2-json' into 'master'
Resolve "Bad Hungarian country name translations in countriesV2.json"

Closes #94

See merge request amatos/rest-countries!36
2021-12-15 15:00:40 +00:00
Alejandro Matos 4f3b1cf4e3 Fixing Hungarian typos 2021-12-15 09:57:22 -05:00
Alejandro Matos 1e086a78d3 Closes #93: Fixing Afghanistan's population according to Wikipedia 2021-12-12 18:03:44 -05:00
Alejandro Matos 09c5671cf8 Security fix 2021-12-11 11:37:13 -05:00
dependabot[bot] 1ad12ae34d Bump log4j-core from 2.14.1 to 2.15.0
Bumps log4j-core from 2.14.1 to 2.15.0.

---
updated-dependencies:
- dependency-name: org.apache.logging.log4j:log4j-core
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-11 16:34:38 +00:00
Alejandro Matos baf690da1e Merge branch 'ajafov98-master-patch-78791' into 'master'
Added missing "independent" field for "Azerbaijan" in countriesV2.json

See merge request amatos/rest-countries!34
2021-12-01 15:08:13 +00:00
Aydin Najafov e744431b09 Added missing "independent" field for "Azerbaijan" in countriesV2.json 2021-12-01 11:41:01 +00:00
Alejandro Matos 562d402969 Merge branch 'master' into 'master'
add build layers in dockerfile

Closes #84

See merge request amatos/rest-countries!32
2021-11-09 18:11:26 +00:00
Charly Coussot e985735b2f add build layers in dockerfile 2021-11-09 16:58:38 +01:00
Alejandro Matos 461db4fa8d Updating readme file 2021-10-19 23:23:19 -05:00
Alejandro Matos 762b134ad7 Adding support for Capital Information, Postal Code 2021-10-19 21:46:01 -05:00
Alejandro Matos ce72e0d301 Merge branch 'ePascalC-master-patch-44048' into 'master'
v3.1 adding data for Postal codes and capital latitude and longtitude

Closes #74

See merge request amatos/rest-countries!31
2021-10-19 17:01:21 +00:00
Pascal Casier e68900022c Update src/main/resources/countriesV3.1.json, FIELDS.md 2021-10-16 18:20:14 +00:00
Alejandro Matos 037bdf1289 Adding COA and start of the week to response 2021-10-15 10:39:54 -05:00
Pascal Casier a2a6ca4db4 Update src/main/resources/countriesV3.1.json, FIELDS.md 2021-10-15 10:36:27 +00:00
Alejandro Matos b29dc0da47 Merge branch 'ePascalC-master-patch-58777' into 'master'
Adding Coat of Arms and Start of Week

Closes #76

See merge request amatos/rest-countries!30
2021-10-13 18:35:47 +00:00
Pascal Casier 4fbf6d0293 Update FIELDS.md, src/main/resources/countriesV3.1.json 2021-10-13 18:09:24 +00:00
Alejandro Matos 513ea55f2f Adding Continent to V3 and Country Structure 2021-10-13 11:24:38 -05:00
Alejandro Matos fa833674bf Merge branch 'ePascalC-master-patch-40542' into 'master'
Adding continents

Closes #51

See merge request amatos/rest-countries!29
2021-10-13 14:54:42 +00:00
Pascal Casier 3c7f7dcb19 Adding 'continents':
Africa,Antarctica,Asia,Europe,North America,Oceania,South America

Added as an array as a country could span multiple continents
2021-10-13 10:41:38 +00:00
Alejandro Matos 34189e20ea Adding timezones to the entity and making it available for filtering 2021-10-12 23:43:33 -05:00
Alejandro Matos bbe18589ad Merge remote-tracking branch 'origin/master' 2021-10-12 23:37:00 -05:00
Alejandro Matos 40325eff46 Closes #72: adding tests and reverting V2 endpoints 2021-10-12 23:36:56 -05:00
Alejandro Matos 5d3bec2afd Merge branch 'ePascalC-master-patch-14962' into 'master'
v3.1 Adding timezones

Closes #70

See merge request amatos/rest-countries!28
2021-10-12 19:22:40 +00:00
Pascal Casier 5642be6868 Update src/main/resources/countriesV3.1.json 2021-10-12 16:38:55 +00:00
Alejandro Matos 01785c6e99 Fixes #75: modifying Lebanon and Singapore COIC codes 2021-10-12 10:23:32 -05:00
Alejandro Matos c4d2fafc58 Merge remote-tracking branch 'origin/master' 2021-10-12 00:49:34 -05:00
Alejandro Matos 7da6c6152f Fixes #73: fixing the structure and filling the blanks 2021-10-12 00:49:17 -05:00
Alejandro Matos dc07c2f20e Merge branch 'ePascalC-master-patch-81245' into 'master'
FIELDS.md : Adding FIFA, fixing typos

See merge request amatos/rest-countries!26
2021-10-12 05:44:34 +00:00
Pascal Casier be129ab93c fix typos 2021-10-12 05:41:53 +00:00
Pascal Casier 1ce6d03d0c Adding FIFA,
Fixing typos
2021-10-12 05:39:02 +00:00
Alejandro Matos b23014b4b8 Fixes #71: Zimbabwe has only one currency 2021-10-12 00:13:02 -05:00
Alejandro Matos 0f40f524d7 Adding the Car node to the Java code 2021-10-11 23:28:06 -05:00
Alejandro Matos 4a9ef14cdb Merge branch 'ePascalC-master-patch-54840' into 'master'
v3.1 Add car information

Closes #69

See merge request amatos/rest-countries!25
2021-10-12 03:47:54 +00:00
Alejandro Matos 04a0db56bc Adding fifa code to the country structure
this applies to v3 and v3.1
2021-10-11 22:39:57 -05:00
Pascal Casier c60c5cc753 Add car information 2021-10-11 19:04:34 +00:00
Alejandro Matos 87e877bb31 Merge branch 'ePascalC-master-patch-73431' into 'master'
As per Issue #67

Closes #67

See merge request amatos/rest-countries!24
2021-10-11 16:00:10 +00:00
Pascal Casier 1cd8e4b0ca As per Issue #67 2021-10-11 15:48:11 +00:00
Alejandro Matos eec59a4e46 Missing space in Fields description 2021-10-11 01:20:34 -05:00
Alejandro Matos d535ee73d4 Updating README and flatdoc 2021-10-11 01:18:19 -05:00
Alejandro Matos 4a8e5f1919 Merge remote-tracking branch 'origin/master' 2021-10-11 00:27:30 -05:00
Alejandro Matos cbfccb4d6f Closes #66: fixing Netherlands' population 2021-10-11 00:27:17 -05:00
Alejandro Matos e20ce02a2e Merge branch 'ePascalC-master-patch-95083' into 'master'
Update FIELDS.md

See merge request amatos/rest-countries!21
2021-10-11 01:02:08 +00:00
Alejandro Matos ed7ed6f7cb Merge branch 'ePascalC-master-patch-51257' into 'master'
Adding fifa codes

See merge request amatos/rest-countries!22
2021-10-11 01:01:31 +00:00
Alejandro Matos c651f4e0e0 Merge branch 'ePascalC-master-patch-19435' into 'master'
v3.1 Add arabic and fix missing cym (Welsh) translations

See merge request amatos/rest-countries!23
2021-10-11 00:37:55 +00:00
Pascal Casier bcebd6ea51 v3.1 Add arabic and fix missing cym (Welsh) translations 2021-10-10 16:10:51 +00:00
Pascal Casier ca2398187d Adding fifa codes 2021-10-10 12:31:08 +00:00
Pascal Casier 0c5d718f20 Update FIELDS.md 2021-10-10 10:35:30 +00:00
Alejandro Matos 538572bd45 Adding gini for v3.x 2021-10-09 12:34:03 -05:00
Alejandro Matos d6a2055d37 Merge branch 'ePascalC-master-patch-68358' into 'master'
v2 Update gini  v3 v31 Prepared data for gini

See merge request amatos/rest-countries!20
2021-10-09 15:34:28 +00:00
Pascal Casier 4f56e96ccf Update FIELDS.md 2021-10-08 06:02:01 +00:00
Pascal Casier cd933d9f8a v2 v3 v31 Update gini 2021-10-07 20:51:45 +00:00
Alejandro Matos ca0c518bb7 Merge branch 'ePascalC-master-patch-31702' into 'master'
Creating fields.md

See merge request amatos/rest-countries!19
2021-10-07 19:09:28 +00:00
Pascal Casier d74f056083 Renaming filename 2021-10-07 19:06:37 +00:00
Alejandro Matos 030f3abef2 Merge branch 'ePascalC-master-patch-64605' into 'master'
V2 Added country translations for cs, pl, ru, se, zh

See merge request amatos/rest-countries!18
2021-10-07 19:01:49 +00:00
Pascal Casier 9edd144399 Update fields.md 2021-10-07 18:00:35 +00:00
Pascal Casier 3f1b14c5a3 Update src/main/resources/countriesV2.json 2021-10-07 07:22:33 +00:00
Alejandro Matos ee33852eb8 Merge branch 'ePascalC-master-patch-47457' 2021-10-06 14:06:51 -05:00
Pascal Casier ba4b931292 Update src/main/resources/countriesV3.1.json, src/main/resources/countriesV3.json, src/main/resources/countriesV2.json 2021-10-06 17:49:14 +00:00
Alejandro Matos db57a83f79 Merge branch 'ePascalC-master-patch-04105' into 'master'
v2 v3 v3.1 Switching flags to FlagCDN

See merge request amatos/rest-countries!16
2021-10-06 14:35:08 +00:00
Pascal Casier b9d1d02332 v2 v3 v3.1 Switching flags to FlagCDN 2021-10-06 14:35:08 +00:00
Alejandro Matos 976d2b2064 Merge branch 'ePascalC-master-patch-76936' into 'master'
Fix: Some JSON interpreter cannot handle the extra ',' at the end.

See merge request amatos/rest-countries!15
2021-10-02 17:28:01 +00:00
Pascal Casier d5ffe9a8fc Fix: Some JSON interpreter cannot handle the extra ',' at the end. 2021-10-02 17:13:40 +00:00
Alejandro Matos 2245dc629b Merge branch 'ePascalC-master-patch-41731' into 'master'
Restoring ALA, HKG and SSD. These are already in v3

See merge request amatos/rest-countries!14
2021-10-02 15:43:15 +00:00
Alejandro Matos c73cab182f Merge branch 'ePascalC-master-patch-27537' into 'master'
v2 - Kosovo KOS to UNK (2)

See merge request amatos/rest-countries!13
2021-10-02 15:40:19 +00:00
Pascal Casier dda9a05942 Restoring ALA, HKG and SSD. These are already in v3 2021-10-02 15:29:51 +00:00
Pascal Casier 580dc39e8c There is no official code yet, but UNK seems to be more frequently used/accepted
Aligning with v3 that is already using UNK
2021-10-02 15:19:51 +00:00
Alejandro Matos cb48f225aa Fixes #51: website was not available 2021-10-01 19:57:12 -05:00
Alejandro Matos c91772cc86 Fixes #59: changing links to Wikipedia 2021-10-01 16:27:06 -05:00
Alejandro Matos f5fef436d3 Fixes #58: adding currency for Micronesia 2021-10-01 11:17:48 -05:00
Alejandro Matos cfa1ebb94f Closes #56: removing empty string in capitals 2021-09-30 19:31:12 -05:00
Alejandro Matos 19f8c78f19 Closes #54: Removing local flags and linking them to wikipedia 2021-09-30 18:33:30 -05:00
Alejandro Matos 4592f9eb87 Closes #52: adding population to V3.x 2021-09-29 14:10:45 -05:00
Alejandro Matos 5a5627ee7b Updating dependencies 2021-09-29 11:44:17 -05:00
Alejandro Matos 5f74df330c Updating Afghan flag 2021-09-29 11:44:02 -05:00
Alejandro Matos 0e0a7f9fc3 Converting spaces into tabs 2021-09-29 11:43:30 -05:00
Alejandro Matos 3395d8ceb8 Merge remote-tracking branch 'origin/master' 2021-09-29 11:41:59 -05:00
Alejandro Matos e24fbf2eb4 Revert "Converting spaces into tabs"
This reverts commit ca36890e8a.
2021-09-29 11:41:48 -05:00
Alejandro Matos ca36890e8a Converting spaces into tabs 2021-09-29 11:40:18 -05:00
Alejandro Matos 8f1f5f6e75 Merge pull request #4 from ePascalC/patch-3
Updating Chad border
2021-09-29 10:54:42 -05:00
ePascalC 64dbf1890c Updating Chad border
Sudan is SDN, not SSN
2021-09-29 17:51:43 +02:00
Alejandro Matos 7d3d517faf Merge pull request #3 from amatosg/revert-2-patch-2
Revert "Capital of Vatican City is Vatican City"
2021-09-29 10:43:17 -05:00
592 changed files with 171993 additions and 95815 deletions
+2
View File
@@ -4,6 +4,7 @@ Thumbs.db
build/
target/
out/
.micronaut/
.idea
*.iml
*.ipr
@@ -11,3 +12,4 @@ out/
.project
.settings
.classpath
.factorypath
+5 -3
View File
@@ -2,7 +2,7 @@ variables:
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
image: adoptopenjdk/openjdk14:alpine-slim
image: eclipse-temurin:17.0.10_7-jdk-alpine
stages:
- package
@@ -36,7 +36,7 @@ docker-push:
- docker info
- cp target/*.jar .
script:
- docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" $REGISTRY_URL
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG
@@ -48,9 +48,11 @@ docker-run:
- apk add openssh-client
- mkdir -p ~/.ssh
- echo "$PRIVATE_VEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 700 ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa
- touch ~/.ssh/known_hosts
- ssh-keygen -R $DEPLOYMENT_SERVER_IP || true
- ssh-keyscan -H $DEPLOYMENT_SERVER_IP >> ~/.ssh/known_hosts
dependencies:
- docker-push
View File
+8
View File
@@ -0,0 +1,8 @@
Please detail the following information when submitting an issue:
* API version:
* Evidence that the data is incorrect:
Please consider donating
* [Paypal](https://www.paypal.me/amatosg/15)
* [Patreon](https://www.patreon.com/amatos)
BIN
View File
Binary file not shown.
+18 -1
View File
@@ -1 +1,18 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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
#
# https://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.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
+77
View File
@@ -0,0 +1,77 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at amatos@gmail.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
+8 -3
View File
@@ -1,4 +1,9 @@
FROM openjdk:14-alpine
COPY target/dev.amatos.restcountries-*.jar dev.amatos.restcountries.jar
FROM maven:3-openjdk-17-slim as build
WORKDIR /
COPY . .
RUN mvn --batch-mode package
FROM openjdk:17-ea-slim
COPY --from=build target/restcountries-*.jar restcountries.jar
EXPOSE 8080
CMD ["java", "-Dcom.sun.management.jmxremote", "-Xmx128m", "-jar", "dev.amatos.restcountries.jar"]
CMD ["java", "-Dcom.sun.management.jmxremote", "-Xmx128m", "-jar", "restcountries.jar"]
+47
View File
@@ -0,0 +1,47 @@
# API data fields
In this table you can find the fields of the different API versions, extra information and sources.
| field | v2 | v3 | v3.1 | Info |
|------------------------|----|----|------|-------------------------------------------------------------------------------------------------|
| alpha2Code / cca2 | v | v | v | ISO 3166-1 alpha-2 two-letter country codes |
| alpha3Code / cca3 | v | v | v | ISO 3166-1 alpha-3 three-letter country codes |
| altSpellings | v | v | v | Alternate spellings of the country name |
| area | v | v | v | Geographical size |
| borders | v | v | v | Border countries |
| callingCodes / idd | v | v | v | International dialing codes |
| capital | v | v | v | Capital cities |
| capitalInfo > latlng | | | | Capital latitude and longitude |
| car > signs | | | v | Car distinguised (oval) signs |
| car > side | | | v | Car driving side |
| cioc | v | v | v | Code of the International Olympic Committee |
| coatOfArms | | | v | [MainFacts.com](https://mainfacts.com/coat-of-arms-countries-world) links to svg and png images |
| continents | | | v | List of continents the country is on |
| currencies | v | v | v | List of all currencies |
| demonym | v | | | Inhabitants of the country |
| demonyms (m/f) | | v | v | Genderized inhabitants of the country |
| independent | v | v | v | ISO 3166-1 independence status (the country is considered a sovereign state) |
| fifa | | | v | FIFA code |
| flag | v | v | v | v2: Link to the svg flag on [Flagpedia](https://flagpedia.net/), v3: flag emoji |
| flags | v | v | v | [Flagpedia](https://flagpedia.net/) links to svg and png flags |
| gini | v | v | v | Worldbank [Gini](https://data.worldbank.org/indicator/SI.POV.GINI) index |
| landlocked | | v | v | Landlocked country |
| languages | v | v | v | List of official languages |
| latlng | v | v | v | Latitude and longitude |
| maps | v | v | v | Link to Google maps and Open Street maps |
| name | v | v | v | Country name |
| name > official/common | | v | v | Official and common country name |
| nativeName | v | v | | Native country name |
| nativeName > official/common | | v | v | Official and common native country name |
| numericCode / ccn3 | v | | | ISO 3166-1 numeric code (UN M49) |
| population | v | v | v | Country population |
| postalCodes > format/regex | | | | Country postal codes |
| region | v | v | v | UN [demographic regions](https://unstats.un.org/unsd/methodology/m49/) |
| regionalBlocs | v | | | |
| startOfWeek | | | | Day of the start of week (Sunday/Monday/Saturday) |
| status | | v | v | ISO 3166-1 assignment status |
| subregion | v | v | v | UN [demographic subregions](https://unstats.un.org/unsd/methodology/m49/) |
| timezones | v | | | Timezones |
| topLevelDomain / tld | v | v | v | Internet top level domains |
| translations | v | v | v | List of country name translations |
| unMember | | v | v | UN Member status |
+84 -264
View File
@@ -1,398 +1,213 @@
# About this Project
This project is inspired on restcountries.eu by Fayder Florez. As it hasn't had any activity in at least 14 months, I decided to take action :)
This project is inspired on restcountries.eu by Fayder Florez. Although the original project has now moved to
a subscription base API, this project is still Open Source and Free to use.
## Important Information About Version 2
The structure has been reverted to its original form from the [Original Project] to maintain compatibility.
## Important Information
* The structure of V2 has been reverted to its original form from the [Original Project] to maintain compatibility.
* ***Only the latest version will receive updates and improvements.***
# REST Countries
You can access API through https://restcountries.com/v3/all
You can access API through https://restcountries.com/v3.1/all
# TODO:
Please reffer to the [issue website](https://gitlab.com/amatos/rest-countries/-/issues)
# Contributing
Any help is welcome! Just edit the file relevant file and create a new Merge Request or you can also
[donate](https://www.paypal.me/amatosg/15).
Any help is always welcome! Just edit the relevant file and create a new Merge Request or you can also
donate using [Patreon](https://www.patreon.com/amatos) or [PayPal](https://www.paypal.me/amatosg/15).
# Donations
Donation will help me paying the server's bills and any upgrade the server might need due to usage so if
you feel like helping me, you're welcome to [donate](https://www.paypal.me/amatosg/15) or you can also
[buy me a coffee](https://www.buymeacoffee.com/amatos).
This are getting out of control. As I stated [here](https://gitlab.com/restcountries/restcountries/-/issues/187), the server is not going to hold much longer. I'm getting about 4 million hits **each day** and that means CPU ussage (99%) and also bandwidth consumption (120 GB **per day!**) so costs have obviously increased. **Please**, consider making a donation on [Patreon](https://www.patreon.com/amatos) or [PayPal](https://www.paypal.me/amatosg/15). This will help me pay the server's bills
# Changelog
### V3
- Added population
### V3.1
- Added population
- Added named object for `flags`
# Fields
You can check the [FIELDS.md](FIELDS.md) file to get a description for each field (thanks to @ePascalC!).
# API Endpoints
Currently there are 3 versions:
- Version 2 is the original version from restcountries.eu by Fayder Florez
- Version 3 is the implementation from [this project](https://github.com/mledoze/countries)
- Version 3.1 adds named values to the `flags` object like this:
## Using this Project
```json
"flags": {
"svg": "https://restcountries.com/data/per.svg",
"png": "https://restcountries.com/data/png/per.png"
}
```
- [Famosos](https://famosos.com)
- [Cultural Care](https://www.culturalcare.world/)
- [Covidata](https://worldcovidata.com/)
- [Asendia](https://tracking.asendia.com)
- [Picker](https://mwb.pickerexpress.com/#/login)
# Endpoints
Below are described the REST endpoints available that you can use to search for countries
## All
## Latest added Endpoint
### V2
### Independent
Now you can get all independent (or not independent) countries by calling this endpoint:
``` html
https://restcountries.com/v2/all
https://restcountries.com/v3.1/independent?status=true
```
If you don't specify the status, true will be taken as default. You can mix it with the `fields` filter like this:
``` html
https://restcountries.com/v3.1/independent?status=true&fields=languages,capital
```
### V3
## All
You **must** specify the fields you need (up to 10 fields) when calling the `all` endpoints,
otherwise you'll get a `bad request` response. Please see [this issue](https://gitlab.com/restcountries/restcountries/-/issues/265)
for more information. This applies to all versions.
``` html
https://restcountries.com/v3/all
https://restcountries.com/v3.1/all
```
## Name
### V2
Search by country name. It can be the native name or partial name
``` javascript
https://restcountries.com/v2/name/{name}
**Search** by country name. If you want to get an exact match, use the next endpoint. It can be the common or official value
``` html
https://restcountries.com/v3.1/name/{name}
```
``` html
https://restcountries.com/v2/name/eesti
https://restcountries.com/v3.1/name/eesti
```
``` html
https://restcountries.com/v2/name/united
```
### V3
Search by country name. It can be the common or official value
``` html
https://restcountries.com/v3/name/{name}
```
``` html
https://restcountries.com/v3/name/eesti
```
``` html
https://restcountries.com/v3/name/deutschland
https://restcountries.com/v3.1/name/deutschland
```
## Full Name
### V2
Search by country's full name
``` html
https://restcountries.com/v2/name/{name}?fullText=true
```
``` html
https://restcountries.com/v2/name/aruba?fullText=true
```
### V3
Search by country's full name. It can be the common or official value
``` html
https://restcountries.com/v3/name/{name}?fullText=true
https://restcountries.com/v3.1/name/{name}?fullText=true
```
``` html
https://restcountries.com/v3/name/aruba?fullText=true
https://restcountries.com/v3.1/name/aruba?fullText=true
```
## Code
### V2
Search by ISO 3166-1 2-letter or 3-letter country code
``` html
https://restcountries.com/v2/alpha/{code}
```
``` html
https://restcountries.com/v2/alpha/co
```
``` html
https://restcountries.com/v2/alpha/col
```
### V3
Search by cca2, ccn3, cca3 or cioc country code (yes, any!)
``` html
https://restcountries.com/v3/alpha/{code}
https://restcountries.com/v3.1/alpha/{code}
```
``` html
https://restcountries.com/v3/alpha/co
https://restcountries.com/v3.1/alpha/co
```
``` html
https://restcountries.com/v3/alpha/col
https://restcountries.com/v3.1/alpha/col
```
``` html
https://restcountries.com/v3/alpha/170
https://restcountries.com/v3.1/alpha/170
```
## List of codes
### V2
Search by list of ISO 3166-1 2-letter or 3-letter country codes
``` html
https://restcountries.com/v2/alpha?codes={code},{code},{code}
```
``` html
https://restcountries.com/v2/alpha?codes=col,no,ee,pe
```
### V3
Search by cca2, ccn3, cca3 or cioc country code (yes, any!)
``` html
https://restcountries.com/v3/alpha?codes={code},{code},{code}
https://restcountries.com/v3.1/alpha?codes={code},{code},{code}
```
``` html
https://restcountries.com/v3/alpha?codes=170,no,est,pe
https://restcountries.com/v3.1/alpha?codes=170,no,est,pe
```
## Currency
### V2
Search by ISO 4217 currency code
``` html
https://restcountries.com/v2/currency/{currency}
```
``` html
https://restcountries.com/v2/currency/cop
```
### V3
Search by currency code or name
``` html
https://restcountries.com/v3/currency/{currency}
https://restcountries.com/v3.1/currency/{currency}
```
``` html
https://restcountries.com/v3/currency/cop
https://restcountries.com/v3.1/currency/cop
```
### Demonym
### V3
## Demonym
Now you can search by how a citizen is called.
``` html
https://restcountries.com/v3/demonym/{demonym}
https://restcountries.com/v3.1/demonym/{demonym}
```
``` html
https://restcountries.com/v3/demonym/peruvian
https://restcountries.com/v3.1/demonym/peruvian
```
## Language
### V2
Search by ISO 639-1 language code
``` javascript
https://restcountries.com/v2/lang/{et}
```
``` html
https://restcountries.com/v2/lang/es
```
### V3
Search by language code or name
``` html
https://restcountries.com/v3/lang/{currency}
https://restcountries.com/v3.1/lang/{currency}
```
``` html
https://restcountries.com/v3/lang/cop
https://restcountries.com/v3.1/lang/cop
```
``` html
https://restcountries.com/v3/lang/spanish
https://restcountries.com/v3.1/lang/spanish
```
## Capital city
_This is the same in both versions_
Search by capital city
``` javascript
https://restcountries.com/v2/capital/{capital}
``` html
https://restcountries.com/v3.1/capital/{capital}
```
``` html
https://restcountries.com/v2/capital/tallinn
```
``` javascript
https://restcountries.com/v3/capital/{capital}
```
``` html
https://restcountries.com/v3/capital/tallinn
https://restcountries.com/v3.1/capital/tallinn
```
## Calling code
### V2
Search by calling code
``` html
https://restcountries.com/v2/callingcode/{callingcode}
```
``` html
https://restcountries.com/v2/callingcode/372
```
### V3
In version 3, calling codes are in the _idd_ object. There is no implementation
to search by calling codes in V3.
## Region
### V2
In version 2 regions are _continent_ and subregions are _region_
Search by continent: Africa, Americas, Asia, Europe, Oceania
Search by region (replace X with the version you want to use)
``` html
https://restcountries.com/v2/continent/{continent}
https://restcountries.com/v3.1/region/{region}
```
``` html
https://restcountries.com/v2/continent/europe
```
### V3
In version 3, continents are _Regions_ and regions are _Subregions_
``` html
https://restcountries.com/v2/region/{region}
```
``` html
https://restcountries.com/v2/region/europe
https://restcountries.com/v3.1/region/europe
```
## Subregions
###V3
You can search by subregions
You can search by subregions (replace X with the version you want to use)
``` html
https://restcountries.com/v2/subregion/{subregion}
https://restcountries.com/v3.1/subregion/{subregion}
```
``` html
https://restcountries.com/v2/subregion/Northern Europe
```
## Regional Bloc (*Version 2 only*)
Search by regional bloc:
- EU (European Union)
- EFTA (European Free Trade Association)
- CARICOM (Caribbean Community)
- PA (Pacific Alliance)
- AU (African Union)
- USAN (Union of South American Nations)
- EEU (Eurasian Economic Union)
- AL (Arab League)
- ASEAN (Association of Southeast Asian Nations)
- CAIS (Central American Integration System)
- CEFTA (Central European Free Trade Agreement)
- NAFTA (North American Free Trade Agreement)
- SAARC (South Asian Association for Regional Cooperation)
``` html
https://restcountries.com/v2/regionalbloc/{regionalbloc}
```
``` html
https://restcountries.com/v2/regionalbloc/eu
https://restcountries.com/v3.1/subregion/Northern Europe
```
## Translation
You can search by any translation name
``` html
https://restcountries.com/v3/translation/{translation}
https://restcountries.com/v3.1/translation/{translation}
```
``` html
https://restcountries.com/v3/translation/germany
https://restcountries.com/v3.1/translation/germany
```
``` html
https://restcountries.com/v3/translation/alemania
https://restcountries.com/v3.1/translation/alemania
```
``` html
https://restcountries.com/v3/translation/Saksamaa
```
## Response Example
``` html
https://restcountries.com/v2/alpha/col
```
``` json
[[{
"name": "Colombia",
"topLevelDomain": [".co"],
"alpha2Code": "CO",
"alpha3Code": "COL",
"callingCodes": ["57"],
"capital": "Bogotá",
"altSpellings": ["CO", "Republic of Colombia", "República de Colombia"],
"region": "Americas",
"subregion": "South America",
"population": 48759958,
"latlng": [4.0, -72.0],
"demonym": "Colombian",
"area": 1141748.0,
"gini": 55.9,
"timezones": ["UTC-05:00"],
"borders": ["BRA", "ECU", "PAN", "PER", "VEN"],
"nativeName": "Colombia",
"numericCode": "170",
"currencies": [{
"code": "COP",
"name": "Colombian peso",
"symbol": "$"
}],
"languages": [{
"iso639_1": "es",
"iso639_2": "spa",
"name": "Spanish",
"nativeName": "Español"
}],
"translations": {
"de": "Kolumbien",
"es": "Colombia",
"fr": "Colombie",
"ja": "コロンビア",
"it": "Colombia",
"br": "Colômbia",
"pt": "Colômbia"
},
"flag": "https://restcountries.com/data/col.svg",
"regionalBlocs": [{
"acronym": "PA",
"name": "Pacific Alliance",
"otherAcronyms": [],
"otherNames": ["Alianza del Pacífico"]
}, {
"acronym": "USAN",
"name": "Union of South American Nations",
"otherAcronyms": ["UNASUR", "UNASUL", "UZAN"],
"otherNames": ["Unión de Naciones Suramericanas", "União de Nações Sul-Americanas", "Unie van Zuid-Amerikaanse Naties", "South American Union"]
}]
}]
https://restcountries.com/v3.1/translation/Saksamaa
```
## Filter Response
You can filter the output of your request to include only the specified fields.
``` javascript
https://restcountries.com/v2/{service}?fields={field},{field},{field}
``` html
https://restcountries.com/v3.1/{service}?fields={field},{field},{field}
```
``` html
https://restcountries.com/v2/all?fields=name,capital,currencies
https://restcountries.com/v3.1/all?fields=name,capital,currencies
```
## Using this Project
## REST Countries Typed API Package
Yusif Aliyev from Azerbaijan created [an npm package](https://www.npmjs.com/package/@yusifaliyevpro/countries)
which provides TypeScript support for the REST Countries API. Everyone can use
the package for their own purpose.
This package offers full type and autocomplete support for anyone using
JavaScript or TypeScript. Users no longer need to spend time reading
documentation or manually writing API URLs and types. You can easily use
all the package's functionalities by calling its functions.
He is also open to contributing further improvements.
- [Nations24](https://nations24.com)
You can find the code [here](https://github.com/yusifaliyevpro/countries)
## Similar projects
* [REST Countries] (original project)
@@ -401,6 +216,7 @@ https://restcountries.com/v2/all?fields=name,capital,currencies
* [REST Countries Ruby]
* [REST Countries Go]
* [REST Countries Python]
* [REST Countries Java]
* [world-currencies]
[world-currencies]: https://github.com/wiredmax/world-currencies
@@ -408,6 +224,10 @@ https://restcountries.com/v2/all?fields=name,capital,currencies
[REST Countries Ruby]: https://github.com/davidesantangelo/restcountry
[REST Countries Go]: https://github.com/alediaferia/gocountries
[REST Countries Python]: https://github.com/SteinRobert/python-restcountries
[REST Countries PHP]: https://github.com/hamedhaghi/countries-client
[Countries of the world]: http://countries.petethompson.net
[REST Countries]: https://github.com/apilayer/restcountries
[Original Project]: https://github.com/apilayer/restcountries/
[donation]: https://www.paypal.me/amatosg/15
[donate]: https://www.paypal.me/amatosg/15
[REST Countries Java]: https://github.com/awais2075/restcountries
+37
View File
@@ -0,0 +1,37 @@
# AOT configuration properties for jar packaging
# Please review carefully the optimizations enabled below
# Check https://micronaut-projects.github.io/micronaut-aot/latest/guide/ for more details
# Caches environment property values: environment properties will be deemed immutable after application startup.
cached.environment.enabled=true
# Precomputes Micronaut configuration property keys from the current environment variables
precompute.environment.properties.enabled=true
# Replaces logback.xml with a pure Java configuration
logback.xml.to.java.enabled=true
# Converts YAML configuration files to Java configuration
yaml.to.java.config.enabled=true
# Scans for service types ahead-of-time, avoiding classpath scanning at startup
serviceloading.jit.enabled=true
# Scans reactive types at build time instead of runtime
scan.reactive.types.enabled=true
# Deduces the environment at build time instead of runtime
deduce.environment.enabled=true
# Checks for the existence of some types at build time instead of runtime
known.missing.types.enabled=true
# Precomputes property sources at build time
sealed.property.source.enabled=true
# The list of service types to be scanned (comma separated)
service.types=io.micronaut.context.env.PropertySourceLoader,io.micronaut.inject.BeanConfiguration,io.micronaut.inject.BeanDefinitionReference,io.micronaut.http.HttpRequestFactory,io.micronaut.http.HttpResponseFactory,io.micronaut.core.beans.BeanIntrospectionReference,io.micronaut.core.convert.TypeConverterRegistrar,io.micronaut.context.env.PropertyExpressionResolver
# A list of types that the AOT analyzer needs to check for existence (comma separated)
known.missing.types.list=io.reactivex.Observable,reactor.core.publisher.Flux,kotlinx.coroutines.flow.Flow,io.reactivex.rxjava3.core.Flowable,io.reactivex.rxjava3.core.Observable,io.reactivex.Single,reactor.core.publisher.Mono,io.reactivex.Maybe,io.reactivex.rxjava3.core.Single,io.reactivex.rxjava3.core.Maybe,io.reactivex.Completable,io.reactivex.rxjava3.core.Completable,io.methvin.watchservice.MacOSXListeningWatchService,io.micronaut.core.async.publisher.CompletableFuturePublisher,io.micronaut.core.async.publisher.Publishers.JustPublisher,io.micronaut.core.async.subscriber.Completable
+2 -2
View File
@@ -1,6 +1,6 @@
applicationType: default
defaultPackage: dev.amatos.restcountries
defaultPackage: com.restcountries
testFramework: junit
sourceLanguage: java
buildTool: maven
features: [app-name, docker, file-watch, http-client, java, java-application, junit, logback, maven, netty-server, readme, shade, yaml]
features: [app-name, http-client, java, java-application, junit, logback, maven, maven-enforcer-plugin, micronaut-aot, micronaut-http-validation, netty-server, properties, readme, serialization-jackson, shade, static-resources, validation]
Vendored
+60 -59
View File
@@ -8,7 +8,7 @@
# "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
# https://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
@@ -19,7 +19,7 @@
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven2 Start Up Batch script
# Apache Maven Wrapper startup batch script, version 3.1.1
#
# Required ENV vars:
# ------------------
@@ -27,7 +27,6 @@
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@@ -36,6 +35,10 @@
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /usr/local/etc/mavenrc ] ; then
. /usr/local/etc/mavenrc
fi
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
@@ -58,9 +61,9 @@ case "`uname`" in
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
JAVA_HOME="`/usr/libexec/java_home`"; export JAVA_HOME
else
export JAVA_HOME="/Library/Java/Home"
JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
fi
fi
;;
@@ -72,36 +75,8 @@ if [ -z "$JAVA_HOME" ] ; then
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
@@ -110,11 +85,8 @@ fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
# TODO classpath?
fi
if [ -z "$JAVA_HOME" ]; then
@@ -146,7 +118,7 @@ if [ -z "$JAVACMD" ] ; then
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
JAVACMD="`\\unset -f command; \\command -v java`"
fi
fi
@@ -160,12 +132,9 @@ if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
@@ -185,7 +154,7 @@ find_maven_basedir() {
fi
# end of workaround
done
echo "${basedir}"
printf '%s' "$(cd "$basedir"; pwd)"
}
# concatenates all lines of a file
@@ -195,11 +164,16 @@ concat_lines() {
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
BASE_DIR=$(find_maven_basedir "$(dirname $0)")
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
@@ -212,40 +186,67 @@ else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar"
if [ -n "$MVNW_REPOURL" ]; then
wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar"
else
wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
case "$key" in (wrapperUrl) wrapperUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
echo "Downloading from: $wrapperUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
QUIET="--quiet"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
QUIET=""
fi
wget "$jarUrl" -O "$wrapperJarPath"
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget $QUIET "$wrapperUrl" -O "$wrapperJarPath"
else
wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath"
fi
[ $? -eq 0 ] || rm -f "$wrapperJarPath"
elif command -v curl > /dev/null; then
QUIET="--silent"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
QUIET=""
fi
curl -o "$wrapperJarPath" "$jarUrl"
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L
else
curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L
fi
[ $? -eq 0 ] || rm -f "$wrapperJarPath"
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
javaSource="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaSource=`cygpath --path --windows "$javaSource"`
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaSource" ]; then
if [ ! -e "$javaClass" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
("$JAVA_HOME/bin/javac" "$javaSource")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ -e "$javaClass" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
@@ -259,16 +260,10 @@ fi
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
@@ -277,10 +272,16 @@ if $cygwin; then
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
Executable → Regular
+187 -161
View File
@@ -1,161 +1,187 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar"
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
echo Found %WRAPPER_JAR%
) else (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
echo Finished downloading %WRAPPER_JAR%
)
@REM End of extension
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Apache Maven Wrapper startup batch script, version 3.1.1
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %WRAPPER_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%
+79 -87
View File
@@ -1,44 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dev.amatos.restcountries</groupId>
<artifactId>dev.amatos.restcountries</artifactId>
<version>1</version>
<groupId>com.restcountries</groupId>
<artifactId>restcountries</artifactId>
<version>2025.04.20</version>
<packaging>${packaging}</packaging>
<parent>
<groupId>io.micronaut</groupId>
<groupId>io.micronaut.platform</groupId>
<artifactId>micronaut-parent</artifactId>
<version>2.0.1</version>
<version>4.7.6</version>
</parent>
<properties>
<jdk.version>14</jdk.version>
<!-- If you are building with JDK 9 or higher, you can uncomment the lines below to set the release version -->
<release.version>14</release.version>
<micronaut.version>2.0.1</micronaut.version>
<exec.mainClass>dev.amatos.restcountries.Application</exec.mainClass>
<java.version>14</java.version>
<packaging>jar</packaging>
<jdk.version>17</jdk.version>
<release.version>17</release.version>
<micronaut.version>4.7.6</micronaut.version>
<micronaut.runtime>netty</micronaut.runtime>
<micronaut.aot.enabled>false</micronaut.aot.enabled>
<micronaut.aot.packageName>com.restcountries.aot.generated</micronaut.aot.packageName>
<exec.mainClass>com.restcountries.Application</exec.mainClass>
</properties>
<repositories>
<repository>
<id>jcenter.bintray.com</id>
<url>https://jcenter.bintray.com</url>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-validation</artifactId>
<artifactId>micronaut-http-client</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
@@ -47,13 +42,18 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-http-client</artifactId>
<groupId>io.micronaut.serde</groupId>
<artifactId>micronaut-serde-jackson</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-runtime</artifactId>
<groupId>io.micronaut.validation</groupId>
<artifactId>micronaut-validation</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
@@ -61,6 +61,11 @@
<artifactId>logback-classic</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.micronaut.test</groupId>
<artifactId>micronaut-test-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
@@ -71,105 +76,92 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.micronaut.test</groupId>
<artifactId>micronaut-test-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-management</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
<version>1.0.1.Beta1</version>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.22.2</version>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.6.0.Final</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.micronaut.build</groupId>
<groupId>io.micronaut.maven</groupId>
<artifactId>micronaut-maven-plugin</artifactId>
<configuration>
<configFile>aot-${packaging}.properties</configFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<artifactId>maven-enforcer-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<!-- Uncomment to enable incremental compilation -->
<!-- <useIncrementalCompilation>false</useIncrementalCompilation> -->
<annotationProcessorPaths>
<annotationProcessorPaths combine.children="append">
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject-java</artifactId>
<version>${micronaut.version}</version>
<artifactId>micronaut-http-validation</artifactId>
<version>${micronaut.core.version}</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-validation</artifactId>
<version>${micronaut.version}</version>
<groupId>io.micronaut.serde</groupId>
<artifactId>micronaut-serde-processor</artifactId>
<version>${micronaut.serialization.version}</version>
<exclusions>
<exclusion>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject</artifactId>
</exclusion>
</exclusions>
</path>
<path>
<groupId>io.micronaut.validation</groupId>
<artifactId>micronaut-validation-processor</artifactId>
<version>${micronaut.validation.version}</version>
<exclusions>
<exclusion>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject</artifactId>
</exclusion>
</exclusions>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Amicronaut.processing.group=dev.amatos.restcountries</arg>
<arg>-Amicronaut.processing.module=dev.amatos.restcountries</arg>
<arg>-Amicronaut.processing.group=com.restcountries</arg>
<arg>-Amicronaut.processing.module=restcountries</arg>
</compilerArgs>
</configuration>
<executions>
<execution>
<id>test-compile</id>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject-java</artifactId>
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-validation</artifactId>
<version>${micronaut.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -1,9 +1,10 @@
package dev.amatos.restcountries;
package com.restcountries;
import io.micronaut.runtime.Micronaut;
public class Application {
public static void main(String[] args) {
Micronaut.run(Application.class, args);
}
}
}
@@ -0,0 +1,105 @@
package com.restcountries.controller;
import com.restcountries.domain.ResponseEntity;
import io.micronaut.http.HttpResponse;
import jakarta.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Optional;
import java.util.stream.Collectors;
import static com.restcountries.utils.Constants.CACHE_CONTROL_VALUE;
import static io.micronaut.http.HttpHeaders.CACHE_CONTROL;
public class ControllerHelper {
protected static final String[] COUNTRY_FIELDS_V2 = new String[]{
"name",
"topLevelDomain",
"alpha2Code",
"alpha3Code",
"callingCodes",
"capital",
"altSpellings",
"region",
"subregion",
"translations",
"population",
"latlng",
"demonym",
"area",
"gini",
"timezones",
"borders",
"nativeName",
"numericCode",
"currencies",
"languages",
"flags",
"regionalBlocs",
"cioc",
"independent",
"continent",
"borders",
"flag",
"flags"
};
protected static HttpResponse<Object> ok(Object object) {
return HttpResponse.ok(object).header(CACHE_CONTROL, CACHE_CONTROL_VALUE);
}
protected static HttpResponse<Object> notFound() {
return HttpResponse.notFound().body(
new ResponseEntity(
Response.Status.NOT_FOUND.getStatusCode(),
Response.Status.NOT_FOUND.getReasonPhrase()
)
);
}
protected static HttpResponse<Object> internalError() {
return HttpResponse.serverError().body(
new ResponseEntity(
Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
Response.Status.INTERNAL_SERVER_ERROR.getReasonPhrase()
)
);
}
protected static HttpResponse<Object> badRequest() {
return HttpResponse.badRequest().body(
new ResponseEntity(
Response.Status.BAD_REQUEST.getStatusCode(),
Response.Status.BAD_REQUEST.getReasonPhrase()
)
);
}
protected static HttpResponse<Object> badAllRequest() {
return HttpResponse.badRequest().body(
new ResponseEntity(
Response.Status.BAD_REQUEST.getStatusCode(),
"'fields' query not specified or you're requesting more than 10 fields"
)
);
}
protected static boolean hasInvalidFields(Optional<String> fields) {
if (fields.isEmpty()) {
return true;
}
var totalFields = Arrays
.stream(fields.get().split(","))
.toList()
.stream()
.map(String::trim)
.collect(Collectors.toCollection(ArrayList::new));
boolean isEmptyOrHasBlank = totalFields.isEmpty() || totalFields.stream().anyMatch(String::isEmpty);
if (isEmptyOrHasBlank || totalFields.size() > 10) {
return true;
}
return false;
}
}
@@ -0,0 +1,122 @@
package com.restcountries.controller;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.restcountries.domain.ICountryRestSymbols;
import com.restcountries.domain.base.BaseCountry;
import java.util.*;
public class ControllerV3Helper {
protected Object checkFieldsAndParseCountries(Optional<String> fields,
Set<? extends com.restcountries.domain.base.BaseCountry> countries) {
if (fields.isPresent()) {
return parsedCountries(countries, fields.get());
} else {
return parsedCountries(countries, null);
}
}
protected Object checkFieldsAndParseCountry(Set<? extends com.restcountries.domain.base.BaseCountry> countries, Optional<String> fields) {
if (fields.isPresent()) {
return parsedCountry(countries, fields.get());
} else {
return parsedCountry(countries, null);
}
}
protected Object parsedCountries(Set<? extends com.restcountries.domain.base.BaseCountry> countries, String excludedFields) {
if (excludedFields == null || excludedFields.isEmpty()) {
return countries;
} else {
return getCountriesJson(countries,
Arrays.asList(excludedFields.split(ICountryRestSymbols.COLON)));
}
}
protected static Object parsedCountry(Set<? extends BaseCountry> countries, String fields) {
if (fields == null || fields.isEmpty()) {
return countries;
} else {
StringBuilder result = new StringBuilder();
countries.forEach(country -> result.append(
getCountryJson(country, Arrays.asList(fields.split(ICountryRestSymbols.COLON)))));
return result;
}
}
private static String getCountryJson(BaseCountry country, List<String> fields) {
var gson = new Gson();
var jsonObject = JsonParser.parseString(gson.toJson(country)).getAsJsonObject();
List<String> excludedFields = new ArrayList<>(Arrays.asList(V3_COUNTRY_FIELDS));
excludedFields.removeAll(fields);
excludedFields.forEach(jsonObject::remove);
return jsonObject.toString();
}
private String getCountriesJson(Set<? extends com.restcountries.domain.base.BaseCountry> countries, List<String> fields) {
var gson = new Gson();
var jsonArray = JsonParser.parseString(gson.toJson(countries)).getAsJsonArray();
var resultArray = new JsonArray();
jsonArray.forEach(element -> {
var jsonObject = (JsonObject) element;
var excludedFields = getExcludedFields(fields);
excludedFields.forEach(jsonObject::remove);
resultArray.add(jsonObject);
});
return resultArray.toString();
}
private List<String> getExcludedFields(List<String> fields) {
List<String> excludedFields = new ArrayList<>(Arrays.asList(V3_COUNTRY_FIELDS));
excludedFields.removeAll(fields);
return excludedFields;
}
boolean isEmpty(String value) {
return value == null || value.isEmpty();
}
protected static final String[] V3_COUNTRY_FIELDS = new String[]{
"name",
"tld",
"cca2",
"ccn3",
"cca3",
"cioc",
"independent",
"status",
"unMember",
"currencies",
"idd",
"region",
"subregion",
"languages",
"translations",
"latlng",
"landlocked",
"borders",
"area",
"flags",
"demonyms",
"population",
"flags",
"flag",
"maps",
"population",
"gini",
"fifa",
"car",
"timezones",
"continents",
"coatOfArms",
"startOfWeek",
"capitalInfo",
"postalCode",
"capital",
"altSpellings"
};
}
@@ -0,0 +1,128 @@
package com.restcountries.controller;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.restcountries.domain.ICountryRestSymbols;
import com.restcountries.domain.v4.Country;
import java.util.*;
public class ControllerV4Helper {
protected Object checkFieldsAndParseCountries(Optional<String> fields, Set<Country> countries) {
if (fields.isPresent()) {
return parsedCountries(countries, fields.get());
} else {
return parsedCountries(countries, null);
}
}
protected Object checkFieldsAndParseCountry(Set<Country> countries, Optional<String> fields) {
if (fields.isPresent()) {
return parsedCountry(countries, fields.get());
} else {
return parsedCountry(countries, null);
}
}
protected Object parsedCountries(Set<Country> countries, String excludedFields) {
if (excludedFields == null || excludedFields.isEmpty()) {
return countries;
} else {
return getCountriesJson(countries,
Arrays.asList(excludedFields.split(ICountryRestSymbols.COLON)));
}
}
protected static Object parsedCountry(Set<Country> countries, String fields) {
if (fields == null || fields.isEmpty()) {
return countries;
} else {
StringBuilder result = new StringBuilder();
countries.forEach(country -> result.append(
getCountryJson(country, Arrays.asList(fields.split(ICountryRestSymbols.COLON)))));
return result;
}
}
private static String getCountryJson(Country country, List<String> fields) {
var gson = new Gson();
var jsonObject = JsonParser.parseString(gson.toJson(country)).getAsJsonObject();
List<String> excludedFields = new ArrayList<>(Arrays.asList(V4_COUNTRY_FIELDS));
excludedFields.removeAll(fields);
excludedFields.forEach(jsonObject::remove);
return jsonObject.toString();
}
private String getCountriesJson(Set<Country> countries, List<String> fields) {
var gson = new Gson();
var jsonArray = JsonParser.parseString(gson.toJson(countries)).getAsJsonArray();
var resultArray = new JsonArray();
jsonArray.forEach(element -> {
var jsonObject = (JsonObject) element;
var excludedFields = getExcludedFields(fields);
excludedFields.forEach(jsonObject::remove);
resultArray.add(jsonObject);
});
return resultArray.toString();
}
private List<String> getExcludedFields(List<String> fields) {
List<String> excludedFields = new ArrayList<>(Arrays.asList(V4_COUNTRY_FIELDS));
excludedFields.removeAll(fields);
return excludedFields;
}
boolean isEmpty(String value) {
return value == null || value.isEmpty();
}
protected static final String[] V4_COUNTRY_FIELDS = new String[]{
"name",
"tld",
"cca2",
"ccn3",
"cca3",
"cioc",
"independent",
"status",
"unMember",
"currencies",
"idd",
"region",
"subregion",
"languages",
"translations",
"landlocked",
"borders",
"area",
"flags",
"demonyms",
"population",
"flag",
"maps",
"gini",
"fifa",
"car",
"timezones",
"continents",
"coatOfArms",
"startOfWeek",
"capitalInfo",
"postalCode",
"capital",
"altSpellings",
"geolocation",
"religion",
"ethnicity",
"government",
"density",
"gdp",
"nationalHoliday",
"anthem",
"regionalBlocs",
"callingCodes"
};
}
@@ -1,56 +1,215 @@
package dev.amatos.restcountries.controller;
package com.restcountries.controller;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import dev.amatos.restcountries.domain.ICountryRestSymbols;
import dev.amatos.restcountries.domain.ResponseEntity;
import dev.amatos.restcountries.service.v2.CountryServiceV2;
import dev.amatos.restcountries.domain.v2.Country;
import com.restcountries.domain.ICountryRestSymbols;
import com.restcountries.domain.v2.Country;
import com.restcountries.service.v2.CountryServiceV2;
import io.micronaut.http.HttpResponse;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.annotation.PathVariable;
import io.micronaut.http.annotation.QueryValue;
import io.swagger.v3.oas.annotations.Hidden;
import javax.ws.rs.QueryParam;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
@Controller("v2/")
public class CountryController {
import static com.restcountries.controller.ControllerHelper.hasInvalidFields;
@Hidden
@Controller("/v2/")
public class CountryControllerV2 {
@Get(uri = "all", produces = MediaType.APPLICATION_JSON)
public Object getAllCountries(@QueryValue("fields") Optional<String> fields) {
if (hasInvalidFields(fields)) {
return ControllerHelper.badAllRequest();
}
List<Country> countries = CountryServiceV2.getInstance().getAll();
return checkFieldsAndParseCountries(fields, countries);
}
private Object checkFieldsAndParseCountries(Optional<String> fields, List<Country> countries) {
if (fields.isPresent()) {
return parsedCountries(countries, fields.get());
} else {
return parsedCountries(countries, null);
}
}
@Get("alpha/{alphacode}")
public Object getByAlpha(@PathVariable("alphacode") String alpha,
public HttpResponse<Object> getByAlpha(@PathVariable("alphacode") String alpha,
@QueryValue("fields") Optional<String> fields) {
if (alpha.contains("codes")) {
alpha = alpha.replace("codes=", "");
}
if (isEmpty(alpha) || alpha.length() < 2 || alpha.length() > 3) {
return getResponse(Response.Status.BAD_REQUEST);
return ControllerHelper.badRequest();
}
Country country = CountryServiceV2.getInstance().getByAlpha(alpha);
if (country != null) {
return checkFieldsAndParseCountry(country, fields);
return ControllerHelper.ok(checkFieldsAndParseCountry(country, fields));
}
return ControllerHelper.notFound();
}
@Get("alpha/")
public HttpResponse<Object> getByAlphaList(@QueryParam("codes") String codes,
@QueryParam("fields") Optional<String> fields) {
if (isEmpty(codes) || codes.length() < 2 || (codes.length() > 3 && !codes.contains(","))) {
return ControllerHelper.badRequest();
}
try {
List<Country> countries = CountryServiceV2.getInstance().getByCodeList(codes);
if (null != countries && !countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("currency/{currency}")
public HttpResponse<Object> getByCurrency(@PathVariable("currency") String currency,
@QueryParam("fields") Optional<String> fields) {
if (isEmpty(currency) || currency.length() != 3) {
return ControllerHelper.badRequest();
}
try {
List<Country> countries = CountryServiceV2.getInstance().getByCurrency(currency);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("name/{name}")
public HttpResponse<Object> getByName(@PathVariable("name") String name,
@QueryParam("fullText") Optional<Boolean> fullText,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance()
.getByName(name, fullText.orElse(false));
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("callingcode/{callingCode}")
public HttpResponse<Object> getByCallingCode(@PathVariable("callingCode") String callingCode,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance().getByCallingCode(callingCode);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("capital/{capital}")
public HttpResponse<Object> getByCapital(@PathVariable("capital") String capital,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance().getByCapital(capital);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("region/{region}")
public HttpResponse<Object> getByContinent(@PathVariable("region") String region,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance().getByRegion(region);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("subregion/{subregion}")
public HttpResponse<Object> getBySubRegion(@PathVariable("subregion") String subregion,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance().getBySubregion(subregion);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("lang/{lang}")
public HttpResponse<Object> getByLanguage(@PathVariable("lang") String language,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance().getByLanguage(language);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("demonym/{demonym}")
public HttpResponse<Object> getByDemonym(@PathVariable("demonym") String demonym,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance().getByDemonym(demonym);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("regionalbloc/{regionalBlock}")
public HttpResponse<Object> getByRegionalBloc(@PathVariable("regionalBlock") String regionalBlock,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance().getByRegionalBloc(regionalBlock);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
private List<Country> checkFieldsAndParseCountries(Optional<String> fields,
List<Country> countries) {
if (fields.isPresent()) {
return parsedCountries(countries, fields.get());
} else {
return parsedCountries(countries, null);
}
return getResponse(Response.Status.NOT_FOUND);
}
private Object checkFieldsAndParseCountry(Country country, Optional<String> fields) {
@@ -61,158 +220,7 @@ public class CountryController {
}
}
@Get("alpha/")
public Object getByAlphaList(@QueryParam("codes") String codes,
@QueryParam("fields") Optional<String> fields) {
if (isEmpty(codes) || codes.length() < 2 || (codes.length() > 3 && !codes.contains(","))) {
return getResponse(Response.Status.BAD_REQUEST);
}
try {
List<Country> countries = CountryServiceV2.getInstance().getByCodeList(codes);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return getResponse(Response.Status.NOT_FOUND);
} catch (Exception e) {
return getResponse(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("currency/{currency}")
public Object getByCurrency(@PathVariable("currency") String currency,
@QueryParam("fields") Optional<String> fields) {
if (isEmpty(currency) || currency.length() != 3) {
return getResponse(Response.Status.BAD_REQUEST);
}
try {
List<Country> countries = CountryServiceV2.getInstance().getByCurrency(currency);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return getResponse(Response.Status.NOT_FOUND);
} catch (Exception e) {
return getResponse(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("name/{name}")
public Object getByName(@PathVariable("name") String name,
@QueryParam("fullText") Optional<Boolean> fullText,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance()
.getByName(name, fullText.orElse(false));
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return getResponse(Response.Status.NOT_FOUND);
} catch (Exception e) {
return getResponse(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("callingcode/{callingCode}")
public Object getByCallingCode(@PathVariable("callingCode") String callingCode,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance().getByCallingCode(callingCode);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return getResponse(Response.Status.NOT_FOUND);
} catch (Exception e) {
return getResponse(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("capital/{capital}")
public Object getByCapital(@PathVariable("capital") String capital,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance().getByCapital(capital);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return getResponse(Response.Status.NOT_FOUND);
} catch (Exception e) {
return getResponse(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("continent/{continent}")
public Object getByContinent(@PathVariable("continent") String region,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance().getByContinent(region);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return getResponse(Response.Status.NOT_FOUND);
} catch (Exception e) {
return getResponse(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("region/{region}")
public Object getBySubRegion(@PathVariable("region") String region,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance().getByRegion(region);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return getResponse(Response.Status.NOT_FOUND);
} catch (Exception e) {
return getResponse(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("lang/{lang}")
public Object getByLanguage(@PathVariable("lang") String language,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance().getByLanguage(language);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return getResponse(Response.Status.NOT_FOUND);
} catch (Exception e) {
return getResponse(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("demonym/{demonym}")
public Object getByDemonym(@PathVariable("demonym") String demonym,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance().getByDemonym(demonym);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return getResponse(Response.Status.NOT_FOUND);
} catch (Exception e) {
return getResponse(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("regionalbloc/{regionalBlock}")
public Object getByRegionalBloc(@PathVariable("regionalBlock") String regionalBlock,
@QueryParam("fields") Optional<String> fields) {
try {
List<Country> countries = CountryServiceV2.getInstance().getByRegionalBloc(regionalBlock);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return getResponse(Response.Status.NOT_FOUND);
} catch (Exception e) {
return getResponse(Response.Status.INTERNAL_SERVER_ERROR);
}
}
private Object parsedCountries(List<Country> countries, String excludedFields) {
private List<Country> parsedCountries(List<Country> countries, String excludedFields) {
if (excludedFields == null || excludedFields.isEmpty()) {
return countries;
} else {
@@ -221,37 +229,28 @@ public class CountryController {
}
}
private String getCountriesJson(List<Country> countries, List<String> fields) {
private List<Country> getCountriesJson(List<Country> countries, List<String> fields) {
List<Country> result = new ArrayList<>();
var gson = new Gson();
var parser = new JsonParser();
JsonArray jsonArray = parser.parse(gson.toJson(countries)).getAsJsonArray();
var resultArray = new JsonArray();
for (var i = 0; i < jsonArray.size(); i++) {
var jsonObject = (JsonObject) jsonArray.get(i);
List<String> excludedFields = getExcludedFields(fields);
for (String excludedField : excludedFields) {
jsonObject.remove(excludedField);
}
resultArray.add(jsonObject);
result.add(gson.fromJson(jsonObject, Country.class));
}
return resultArray.toString();
return result;
}
private List<String> getExcludedFields(List<String> fields) {
List<String> excludedFields = new ArrayList<>(Arrays.asList(COUNTRY_FIELDS));
List<String> excludedFields = new ArrayList<>(Arrays.asList(ControllerHelper.COUNTRY_FIELDS_V2));
excludedFields.removeAll(fields);
return excludedFields;
}
private Object getResponse(Response.Status status) {
var gson = new Gson();
return Response
.status(status)
.entity(gson.toJson(new ResponseEntity(status.getStatusCode(),
status.getReasonPhrase()))).build().getEntity();
}
private Object parsedCountry(Country country, String fields) {
if (fields == null || fields.isEmpty()) {
return country;
@@ -272,38 +271,6 @@ public class CountryController {
return jsonObject.toString();
}
private static final String[] COUNTRY_FIELDS = new String[]{
"name",
"topLevelDomain",
"alpha2Code",
"alpha3Code",
"callingCodes",
"capital",
"altSpellings",
"region",
"subregion",
"translations",
"population",
"latlng",
"demonym",
"area",
"gini",
"timezones",
"borders",
"nativeName",
"numericCode",
"currencies",
"languages",
"flags",
"regionalBlocs",
"cioc",
"independent",
"continent",
"borders",
"flag",
"flags"
};
private boolean isEmpty(String value) {
return value == null || value.isEmpty();
}
@@ -0,0 +1,182 @@
package com.restcountries.controller;
import com.restcountries.service.v3.CountryServiceV3;
import io.micronaut.http.HttpResponse;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.annotation.PathVariable;
import io.micronaut.http.annotation.QueryValue;
import io.swagger.v3.oas.annotations.Hidden;
import javax.ws.rs.QueryParam;
import java.util.Optional;
import static com.restcountries.controller.ControllerHelper.hasInvalidFields;
@Hidden
@Controller("/v3/")
public class CountryControllerV3 extends ControllerV3Helper {
@Get(uri = "all", produces = MediaType.APPLICATION_JSON)
public HttpResponse<Object> getAllCountries(@QueryValue("fields") Optional<String> fields) {
if (hasInvalidFields(fields)) {
return ControllerHelper.badAllRequest();
}
var countries = CountryServiceV3.getInstance().getAll();
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
@Get("alpha/{alphacode}")
public HttpResponse<Object> getByAlpha(@PathVariable("alphacode") String alpha,
@QueryValue("fields") Optional<String> fields) {
if (alpha.contains("codes")) {
alpha = alpha.replace("codes=", "");
}
if (isEmpty(alpha) || alpha.length() < 2 || alpha.length() > 3) {
return ControllerHelper.badRequest();
}
var country = CountryServiceV3.getInstance().getByAlpha(alpha);
if (country != null && !country.isEmpty()) {
return HttpResponse.ok(checkFieldsAndParseCountry(country, fields));
}
return ControllerHelper.notFound();
}
@Get("alpha/")
public HttpResponse<Object> getByAlphaList(@QueryParam("codes") String codes,
@QueryParam("fields") Optional<String> fields) {
if (isEmpty(codes) || codes.length() < 2 || (codes.length() > 3 && !codes.contains(","))) {
return ControllerHelper.badRequest();
}
try {
var countries = CountryServiceV3.getInstance().getByCodeList(codes);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("currency/{currency}")
public HttpResponse<Object> getByCurrency(@PathVariable("currency") String currency,
@QueryParam("fields") Optional<String> fields) {
if (isEmpty(currency)) {
return ControllerHelper.notFound();
}
try {
var countries = CountryServiceV3.getInstance().getByCurrency(currency);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("name/{name}")
public HttpResponse<Object> getByName(@PathVariable("name") String name,
@QueryParam("fullText") Optional<Boolean> fullText,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV3.getInstance()
.getByName(name, fullText.orElse(false));
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("capital/{capital}")
public HttpResponse<Object> getByCapital(@PathVariable("capital") String capital,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV3.getInstance().getByCapital(capital);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("region/{region}")
public HttpResponse<Object> getByContinent(@PathVariable("region") String region,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV3.getInstance().getByRegion(region);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("subregion/{subregion}")
public HttpResponse<Object> getBySubRegion(@PathVariable("subregion") String subregion,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV3.getInstance().getBySubregion(subregion);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("lang/{lang}")
public HttpResponse<Object> getByLanguage(@PathVariable("lang") String language,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV3.getInstance().getByLanguage(language);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("demonym/{demonym}")
public HttpResponse<Object> getByDemonym(@PathVariable("demonym") String demonym,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV3.getInstance().getByDemonym(demonym);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("translation/{translation}")
public HttpResponse<Object> getByTranslation(@PathVariable("translation") String translation,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV3.getInstance().getByTranslation(translation);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
}
@@ -0,0 +1,210 @@
package com.restcountries.controller;
import com.restcountries.service.v3.v31.CountryServiceV31;
import io.micronaut.http.HttpResponse;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.annotation.PathVariable;
import io.micronaut.http.annotation.QueryValue;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import java.util.Optional;
import static com.restcountries.controller.ControllerHelper.hasInvalidFields;
@Controller("/v3.1/")
public class CountryControllerV31 extends ControllerV3Helper {
@Get(uri = "all", produces = MediaType.APPLICATION_JSON)
@Schema(name = "RestCountries")
public Object getAllCountries(@QueryValue("fields") Optional<String> fields) {
if (hasInvalidFields(fields)) {
return ControllerHelper.badAllRequest();
}
var countries = CountryServiceV31.getInstance().getAll();
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
@Get("alpha/{alphacode}")
@Schema(name = "RestCountries")
public Object getByAlpha(@PathVariable("alphacode") String alpha,
@QueryValue("fields") Optional<String> fields) {
if (alpha.contains("codes")) {
alpha = alpha.replace("codes=", "");
}
if (isEmpty(alpha) || alpha.length() < 2 || alpha.length() > 3) {
return ControllerHelper.badRequest();
}
var country = CountryServiceV31.getInstance().getByAlpha(alpha);
if (country != null && !country.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountry(country, fields));
}
return ControllerHelper.notFound();
}
@Get("alpha/")
@Schema(name = "RestCountries")
public Object getByAlphaList(@QueryParam("codes") String codes,
@QueryParam("fields") Optional<String> fields) {
if (isEmpty(codes) || codes.length() < 2 || (codes.length() > 3 && !codes.contains(","))) {
return ControllerHelper.badRequest();
}
try {
var countries = CountryServiceV31.getInstance().getByCodeList(codes);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("currency/{currency}")
@Schema(name = "RestCountries")
public Object getByCurrency(@PathVariable("currency") String currency,
@QueryParam("fields") Optional<String> fields) {
if (isEmpty(currency)) {
return ControllerHelper.badRequest();
}
try {
var countries = CountryServiceV31.getInstance().getByCurrency(currency);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("name/{name}")
@Schema(name = "RestCountries")
public Object getByName(@PathVariable("name") String name,
@QueryParam("fullText") Optional<Boolean> fullText,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV31.getInstance().getByName(name, fullText.orElse(false));
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("capital/{capital}")
@Schema(name = "RestCountries")
public Object getByCapital(@PathVariable("capital") String capital,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV31.getInstance().getByCapital(capital);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("region/{region}")
@Schema(name = "RestCountries")
public Object getByContinent(@PathVariable("region") String region,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV31.getInstance().getByRegion(region);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("subregion/{subregion}")
@Schema(name = "RestCountries")
public Object getBySubRegion(@PathVariable("subregion") String subregion,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV31.getInstance().getBySubregion(subregion);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("lang/{lang}")
@Schema(name = "RestCountries")
public Object getByLanguage(@PathVariable("lang") String language,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV31.getInstance().getByLanguage(language);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("demonym/{demonym}")
@Schema(name = "RestCountries")
public Object getByDemonym(@PathVariable("demonym") String demonym,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV31.getInstance().getByDemonym(demonym);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("translation/{translation}")
@Schema(name = "RestCountries")
public Object getByTranslation(@PathVariable("translation") String translation,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV31.getInstance().getByTranslation(translation);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("independent")
@Schema(name = "RestCountries")
public Object getIndependentCountries(@QueryParam("status") Optional<Boolean> status, @QueryParam("fields") Optional<String> fields) {
try {
var result = true;
if (status.isPresent()) {
result = Boolean.TRUE.equals(status.get());
}
var countries = CountryServiceV31.getInstance().getIndependent(result);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
}
@@ -0,0 +1,208 @@
package com.restcountries.controller;
import com.restcountries.service.v4.CountryServiceV4;
import io.micronaut.http.HttpResponse;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.annotation.PathVariable;
import io.micronaut.http.annotation.QueryValue;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import java.util.Optional;
import static com.restcountries.controller.ControllerHelper.hasInvalidFields;
@Controller("/v4/")
public class CountryControllerV4 extends ControllerV4Helper {
@Get(uri = "all", produces = MediaType.APPLICATION_JSON)
@Schema(name = "RestCountries")
public Object getAllCountries(@QueryValue("fields") Optional<String> fields) {
if (hasInvalidFields(fields)) {
return ControllerHelper.badAllRequest();
}
var countries = CountryServiceV4.getInstance().getAll();
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
@Get("alpha/{alphacode}")
@Schema(name = "RestCountries")
public Object getByAlpha(@PathVariable("alphacode") String alpha,
@QueryValue("fields") Optional<String> fields) {
if (alpha.contains("codes")) {
alpha = alpha.replace("codes=", "");
}
if (isEmpty(alpha) || alpha.length() < 2 || alpha.length() > 3) {
return ControllerHelper.badRequest();
}
var country = CountryServiceV4.getInstance().getByAlpha(alpha);
if (country != null && !country.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountry(country, fields));
}
return ControllerHelper.notFound();
}
@Get("alpha/")
@Schema(name = "RestCountries")
public Object getByAlphaList(@QueryParam("codes") String codes,
@QueryParam("fields") Optional<String> fields) {
if (isEmpty(codes) || codes.length() < 2 || (codes.length() > 3 && !codes.contains(","))) {
return ControllerHelper.badRequest();
}
try {
var countries = CountryServiceV4.getInstance().getByCodeList(codes);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("currency/{currency}")
@Schema(name = "RestCountries")
public Object getByCurrency(@PathVariable("currency") String currency,
@QueryParam("fields") Optional<String> fields) {
if (isEmpty(currency)) {
return ControllerHelper.badRequest();
}
try {
var countries = CountryServiceV4.getInstance().getByCurrency(currency);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return ControllerHelper.internalError();
}
}
@Get("name/{name}")
@Schema(name = "RestCountries")
public Object getByName(@PathVariable("name") String name,
@QueryParam("fullText") Optional<Boolean> fullText,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV4.getInstance().getByName(name, fullText.orElse(false));
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("capital/{capital}")
@Schema(name = "RestCountries")
public Object getByCapital(@PathVariable("capital") String capital,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV4.getInstance().getByCapital(capital);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("region/{region}")
@Schema(name = "RestCountries")
public Object getByContinent(@PathVariable("region") String region,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV4.getInstance().getByRegion(region);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("subregion/{subregion}")
@Schema(name = "RestCountries")
public Object getBySubRegion(@PathVariable("subregion") String subregion,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV4.getInstance().getBySubregion(subregion);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("lang/{lang}")
@Schema(name = "RestCountries")
public Object getByLanguage(@PathVariable("lang") String language,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV4.getInstance().getByLanguage(language);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("demonym/{demonym}")
@Schema(name = "RestCountries")
public Object getByDemonym(@PathVariable("demonym") String demonym,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV4.getInstance().getByDemonym(demonym);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("translation/{translation}")
@Schema(name = "RestCountries")
public Object getByTranslation(@PathVariable("translation") String translation,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV4.getInstance().getByTranslation(translation);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("independent")
@Schema(name = "RestCountries")
public Object getIndependentCountries(@QueryParam("status") Optional<Boolean> status,
@QueryParam("fields") Optional<String> fields) {
try {
var result = true;
if (status.isPresent()) {
result = Boolean.TRUE.equals(status.get());
}
var countries = CountryServiceV4.getInstance().getIndependent(result);
if (!countries.isEmpty()) {
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
}
return ControllerHelper.notFound();
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
}
@@ -1,8 +1,11 @@
package dev.amatos.restcountries.domain;
package com.restcountries.domain;
import io.micronaut.serde.annotation.Serdeable;
import java.util.List;
import java.util.Map;
@Serdeable.Serializable
public class BaseCountry {
protected String name;
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package dev.amatos.restcountries.domain;
package com.restcountries.domain;
public interface ICountryRestSymbols {
String COLON = ",";
@@ -1,8 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package dev.amatos.restcountries.domain;
package com.restcountries.domain;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class ResponseEntity {
private final int status;
@@ -0,0 +1,104 @@
package com.restcountries.domain.base;
import io.micronaut.serde.annotation.Serdeable;
import java.util.List;
import java.util.Map;
@Serdeable.Serializable
public class BaseCountry extends BaseCountryCore {
private Name name;
private Map<String, Currency> currencies;
private Map<String, String> languages;
private Map<String, Map<String, String>> translations;
private List<Double> latlng;
private Map<String, Map<String, String>> demonyms;
private Map<String, Double> gini;
public Name getName() {
return name;
}
public void setName(Name name) {
this.name = name;
}
public Map<String, Currency> getCurrencies() {
return currencies;
}
public void setCurrencies(
Map<String, Currency> currencies) {
this.currencies = currencies;
}
public Map<String, String> getLanguages() {
return languages;
}
public void setLanguages(Map<String, String> languages) {
this.languages = languages;
}
public List<Double> getLatlng() {
return latlng;
}
public void setLatlng(List<Double> latlng) {
this.latlng = latlng;
}
public Map<String, Map<String, String>> getDemonyms() {
return demonyms;
}
public void setDemonyms(
Map<String, Map<String, String>> demonyms) {
this.demonyms = demonyms;
}
@Override
public String toString() {
return "Country{" + "\n" +
"NativeName=" + name.getNativeName() + "\n" +
"Common=" + name.getCommon() + "\n" +
"Official=" + name.getOfficial() + "\n" +
", tld=" + getTld() + "\n" +
", cca2='" + getCca2() + '\'' + "\n" +
", ccn3='" + getCcn3() + '\'' + "\n" +
", cioc='" + getCioc() + '\'' + "\n" +
", independent=" + getIndependent() + "\n" +
", status='" + getStatus() + '\'' + "\n" +
", unMember=" + getUnMember() + "\n" +
", currencies=" + currencies + "\n" +
", idd=" + getIdd() + "\n" +
", capital=" + getCapital() + "\n" +
", altSpelling=" + getAltSpellings() + "\n" +
", region='" + getRegion() + '\'' + "\n" +
", subregion='" + getSubregion() + '\'' + "\n" +
", language=" + languages + "\n" +
", latlng=" + latlng + "\n" +
", landlocked=" + getLandlocked() + "\n" +
", borders=" + getBorders() + "\n" +
", area=" + getArea() + "\n" +
", demonyms=" + demonyms + "\n" +
'}';
}
public Map<String, Map<String, String>> getTranslations() {
return translations;
}
public void setTranslations(Map<String, Map<String, String>> translations) {
this.translations = translations;
}
public Map<String, Double> getGini() {
return gini;
}
public void setGini(Map<String, Double> gini) {
this.gini = gini;
}
}
@@ -1,10 +1,13 @@
package dev.amatos.restcountries.domain.base;
package com.restcountries.domain.base;
import io.micronaut.serde.annotation.Serdeable;
import java.util.List;
import java.util.Map;
public class BaseCountry {
private Name name;
@Serdeable.Serializable
public abstract class BaseCountryCore {
private List<String> tld;
private String cca2;
private String ccn3;
@@ -13,30 +16,22 @@ public class BaseCountry {
private Boolean independent;
private String status;
private Boolean unMember;
private Map<String, Currency> currencies;
private Idd idd;
private List<String> capital;
private List<String> altSpellings;
private String region;
private String subregion;
private Map<String, String> languages;
private Map<String, Map<String, String>> translations;
private List<Double> latlng;
private Boolean landlocked;
private List<String> borders;
private Double area;
private Map<String, Map<String, String>> demonyms;
private List<String> callingCodes;
private String flag;
private Map<String, String> maps;
public Name getName() {
return name;
}
public void setName(Name name) {
this.name = name;
}
private Integer population;
private String fifa;
private Car car;
private List<String> timezones;
private List<String> continents;
public List<String> getTld() {
return tld;
@@ -62,6 +57,14 @@ public class BaseCountry {
this.ccn3 = ccn3;
}
public String getCca3() {
return cca3;
}
public void setCca3(String cca3) {
this.cca3 = cca3;
}
public String getCioc() {
return cioc;
}
@@ -94,15 +97,6 @@ public class BaseCountry {
this.unMember = unMember;
}
public Map<String, Currency> getCurrencies() {
return currencies;
}
public void setCurrencies(
Map<String, Currency> currencies) {
this.currencies = currencies;
}
public Idd getIdd() {
return idd;
}
@@ -143,22 +137,6 @@ public class BaseCountry {
this.subregion = subregion;
}
public Map<String, String> getLanguages() {
return languages;
}
public void setLanguages(Map<String, String> languages) {
this.languages = languages;
}
public List<Double> getLatlng() {
return latlng;
}
public void setLatlng(List<Double> latlng) {
this.latlng = latlng;
}
public Boolean getLandlocked() {
return landlocked;
}
@@ -183,59 +161,6 @@ public class BaseCountry {
this.area = area;
}
public Map<String, Map<String, String>> getDemonyms() {
return demonyms;
}
public void setDemonyms(
Map<String, Map<String, String>> demonyms) {
this.demonyms = demonyms;
}
@Override
public String toString() {
return "Country{" + "\n" +
"NativeName=" + name.getNativeName() + "\n" +
"Common=" + name.getCommon() + "\n" +
"Official=" + name.getOfficial() + "\n" +
", tld=" + tld + "\n" +
", cca2='" + cca2 + '\'' + "\n" +
", ccn3='" + ccn3 + '\'' + "\n" +
", cioc='" + cioc + '\'' + "\n" +
", independent=" + independent + "\n" +
", status='" + status + '\'' + "\n" +
", unMember=" + unMember + "\n" +
", currencies=" + currencies + "\n" +
", idd=" + idd + "\n" +
", capital=" + capital + "\n" +
", altSpelling=" + altSpellings + "\n" +
", region='" + region + '\'' + "\n" +
", subregion='" + subregion + '\'' + "\n" +
", language=" + languages + "\n" +
", latlng=" + latlng + "\n" +
", landlocked=" + landlocked + "\n" +
", borders=" + borders + "\n" +
", area=" + area + "\n" +
", demonyms=" + demonyms + "\n" +
'}';
}
public String getCca3() {
return cca3;
}
public void setCca3(String cca3) {
this.cca3 = cca3;
}
public Map<String, Map<String, String>> getTranslations() {
return translations;
}
public void setTranslations(Map<String, Map<String, String>> translations) {
this.translations = translations;
}
public List<String> getCallingCodes() {
return callingCodes;
}
@@ -259,4 +184,44 @@ public class BaseCountry {
public void setMaps(Map<String, String> maps) {
this.maps = maps;
}
public Integer getPopulation() {
return population;
}
public void setPopulation(Integer population) {
this.population = population;
}
public String getFifa() {
return fifa;
}
public void setFifa(String fifa) {
this.fifa = fifa;
}
public Car getCar() {
return car;
}
public void setCar(Car car) {
this.car = car;
}
public List<String> getTimezones() {
return timezones;
}
public void setTimezones(List<String> timezones) {
this.timezones = timezones;
}
public List<String> getContinents() {
return continents;
}
public void setContinents(List<String> continents) {
this.continents = continents;
}
}
@@ -0,0 +1,27 @@
package com.restcountries.domain.base;
import io.micronaut.serde.annotation.Serdeable;
import java.util.List;
@Serdeable.Serializable
public class Car {
private List<String> signs;
private String side;
public List<String> getSigns() {
return signs;
}
public void setSigns(List<String> signs) {
this.signs = signs;
}
public String getSide() {
return side;
}
public void setSide(String side) {
this.side = side;
}
}
@@ -1,5 +1,8 @@
package dev.amatos.restcountries.domain.base;
package com.restcountries.domain.base;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Currency {
private String name;
private String symbol;
@@ -1,7 +1,10 @@
package dev.amatos.restcountries.domain.base;
package com.restcountries.domain.base;
import io.micronaut.serde.annotation.Serdeable;
import java.util.List;
@Serdeable.Serializable
public class Idd {
private String root;
private List<String> suffixes;
@@ -1,12 +1,18 @@
package dev.amatos.restcountries.domain.base;
package com.restcountries.domain.base;
import io.micronaut.serde.annotation.Serdeable;
import java.util.List;
import java.util.Map;
@Serdeable.Serializable
public class Name {
private String common;
private String official;
private Map<String, NativeName> nativeName;
private List<String> altSpellings;
public String getCommon() {
return common;
}
@@ -31,4 +37,12 @@ public class Name {
Map<String, NativeName> nativeName) {
this.nativeName = nativeName;
}
public List<String> getAltSpellings() {
return altSpellings;
}
public void setAltSpellings(List<String> altSpellings) {
this.altSpellings = altSpellings;
}
}
@@ -1,5 +1,8 @@
package dev.amatos.restcountries.domain.base;
package com.restcountries.domain.base;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class NativeName {
private String official;
private String common;
@@ -1,4 +1,4 @@
package dev.amatos.restcountries.domain.v2;
package com.restcountries.domain.v2;
/**
* Created by fayder on 24/02/2017.
@@ -1,13 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package dev.amatos.restcountries.domain.v2;
package com.restcountries.domain.v2;
import com.restcountries.domain.BaseCountry;
import io.micronaut.serde.annotation.Serdeable;
import dev.amatos.restcountries.domain.BaseCountry;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Serdeable.Serializable
public class Country extends BaseCountry {
private List<Currency> currencies;
@@ -1,8 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package dev.amatos.restcountries.domain.v2;
package com.restcountries.domain.v2;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Currency {
private String code;
@@ -1,5 +1,8 @@
package dev.amatos.restcountries.domain.v2;
package com.restcountries.domain.v2;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Flag {
private String svg;
private String png;
@@ -1,8 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package dev.amatos.restcountries.domain.v2;
package com.restcountries.domain.v2;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Language {
private String iso639_1;
@@ -1,5 +1,8 @@
package dev.amatos.restcountries.domain.v2;
package com.restcountries.domain.v2;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Maps {
private String gmaps;
private String openstreetmap;
@@ -1,4 +1,6 @@
package dev.amatos.restcountries.domain.v2;
package com.restcountries.domain.v2;
import io.micronaut.serde.annotation.Serdeable;
import java.util.ArrayList;
import java.util.List;
@@ -6,6 +8,7 @@ import java.util.List;
/**
* Created by fayder on 30/04/2017.
*/
@Serdeable.Serializable
public class RegionalBloc {
private String acronym;
@@ -1,9 +1,12 @@
package dev.amatos.restcountries.domain.v2;
package com.restcountries.domain.v2;
import io.micronaut.serde.annotation.Serdeable;
/**
* Created by fayder on 05/03/2017.
*/
@Serdeable.Serializable
public class Translations {
private String br;
@@ -1,8 +1,11 @@
package dev.amatos.restcountries.domain.v3;
package com.restcountries.domain.v3;
import com.restcountries.domain.base.BaseCountry;
import io.micronaut.serde.annotation.Serdeable;
import dev.amatos.restcountries.domain.base.BaseCountry;
import java.util.List;
@Serdeable.Serializable
public class Country extends BaseCountry {
private List<String> flags;
@@ -0,0 +1,19 @@
package com.restcountries.domain.v3.v31;
import io.micronaut.serde.annotation.Serdeable;
import java.util.List;
@Serdeable.Serializable
public class CapitalInformation {
private List<Double> latlng;
public List<Double> getLatlng() {
return latlng;
}
public void setLatlng(List<Double> latlng) {
this.latlng = latlng;
}
}
@@ -0,0 +1,55 @@
package com.restcountries.domain.v3.v31;
import com.restcountries.domain.base.BaseCountry;
import io.micronaut.serde.annotation.Serdeable;
import java.util.Map;
@Serdeable.Serializable
public class Country extends BaseCountry {
private Flag flags;
private Flag coatOfArms;
private String startOfWeek;
private CapitalInformation capitalInfo;
private Map<String, String> postalCode;
public Flag getFlags() {
return flags;
}
public void setFlags(Flag flags) {
this.flags = flags;
}
public Flag getCoatOfArms() {
return coatOfArms;
}
public void setCoatOfArms(Flag coatOfArms) {
this.coatOfArms = coatOfArms;
}
public String getStartOfWeek() {
return startOfWeek;
}
public void setStartOfWeek(String startOfWeek) {
this.startOfWeek = startOfWeek;
}
public CapitalInformation getCapitalInfo() {
return capitalInfo;
}
public void setCapitalInfo(CapitalInformation capitalInfo) {
this.capitalInfo = capitalInfo;
}
public Map<String, String> getPostalCode() {
return postalCode;
}
public void setPostalCode(Map<String, String> postalCode) {
this.postalCode = postalCode;
}
}
@@ -0,0 +1,34 @@
package com.restcountries.domain.v3.v31;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Flag {
private String png;
private String svg;
private String alt;
public String getPng() {
return png;
}
public void setPng(String png) {
this.png = png;
}
public String getSvg() {
return svg;
}
public void setSvg(String svg) {
this.svg = svg;
}
public String getAlt() {
return alt;
}
public void setAlt(String alt) {
this.alt = alt;
}
}
@@ -0,0 +1,203 @@
package com.restcountries.domain.v4;
import com.restcountries.domain.base.BaseCountryCore;
import com.restcountries.domain.v3.v31.CapitalInformation;
import com.restcountries.domain.v3.v31.Flag;
import io.micronaut.serde.annotation.Serdeable;
import java.util.List;
import java.util.Map;
@Serdeable.Serializable
public class Country extends BaseCountryCore {
private Name name;
private List<Currency> currencies;
private List<Language> languages;
private List<Translation> translations;
private List<Demonym> demonyms;
private List<Gini> gini;
private Flag flags;
private Flag coatOfArms;
private String startOfWeek;
private CapitalInformation capitalInfo;
private Map<String, String> postalCode;
private Geolocation geolocation;
private List<Religion> religion;
private List<Ethnicity> ethnicity;
private Government government;
private Double density;
private GDP gdp;
private String nationalHoliday;
private String anthem;
private List<RegionalBloc> regionalBlocs;
private Double hdi;
public Name getName() {
return name;
}
public void setName(Name name) {
this.name = name;
}
public List<Currency> getCurrencies() {
return currencies;
}
public void setCurrencies(List<Currency> currencies) {
this.currencies = currencies;
}
public List<Language> getLanguages() {
return languages;
}
public void setLanguages(List<Language> languages) {
this.languages = languages;
}
public List<Translation> getTranslations() {
return translations;
}
public void setTranslations(List<Translation> translations) {
this.translations = translations;
}
public List<Demonym> getDemonyms() {
return demonyms;
}
public void setDemonyms(List<Demonym> demonyms) {
this.demonyms = demonyms;
}
public List<Gini> getGini() {
return gini;
}
public void setGini(List<Gini> gini) {
this.gini = gini;
}
public Flag getFlags() {
return flags;
}
public void setFlags(Flag flags) {
this.flags = flags;
}
public Flag getCoatOfArms() {
return coatOfArms;
}
public void setCoatOfArms(Flag coatOfArms) {
this.coatOfArms = coatOfArms;
}
public String getStartOfWeek() {
return startOfWeek;
}
public void setStartOfWeek(String startOfWeek) {
this.startOfWeek = startOfWeek;
}
public CapitalInformation getCapitalInfo() {
return capitalInfo;
}
public void setCapitalInfo(CapitalInformation capitalInfo) {
this.capitalInfo = capitalInfo;
}
public Map<String, String> getPostalCode() {
return postalCode;
}
public void setPostalCode(Map<String, String> postalCode) {
this.postalCode = postalCode;
}
public Geolocation getGeolocation() {
return geolocation;
}
public void setGeolocation(Geolocation geolocation) {
this.geolocation = geolocation;
}
public List<Religion> getReligion() {
return religion;
}
public void setReligion(List<Religion> religion) {
this.religion = religion;
}
public List<Ethnicity> getEthnicity() {
return ethnicity;
}
public void setEthnicity(List<Ethnicity> ethnicity) {
this.ethnicity = ethnicity;
}
public Government getGovernment() {
return government;
}
public void setGovernment(Government government) {
this.government = government;
}
public Double getDensity() {
return density;
}
public void setDensity(Double density) {
this.density = density;
}
public GDP getGdp() {
return gdp;
}
public void setGdp(GDP gdp) {
this.gdp = gdp;
}
public String getNationalHoliday() {
return nationalHoliday;
}
public void setNationalHoliday(String nationalHoliday) {
this.nationalHoliday = nationalHoliday;
}
public String getAnthem() {
return anthem;
}
public void setAnthem(String anthem) {
this.anthem = anthem;
}
public List<RegionalBloc> getRegionalBlocs() {
return regionalBlocs;
}
public void setRegionalBlocs(List<RegionalBloc> regionalBlocs) {
this.regionalBlocs = regionalBlocs;
}
public Double getHdi() {
return hdi;
}
public void setHdi(Double hdi) {
this.hdi = hdi;
}
}
@@ -0,0 +1,34 @@
package com.restcountries.domain.v4;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Currency {
private String code;
private String name;
private String symbol;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
}
@@ -0,0 +1,34 @@
package com.restcountries.domain.v4;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Demonym {
private String lang;
private String male;
private String female;
public String getLang() {
return lang;
}
public void setLang(String lang) {
this.lang = lang;
}
public String getMale() {
return male;
}
public void setMale(String male) {
this.male = male;
}
public String getFemale() {
return female;
}
public void setFemale(String female) {
this.female = female;
}
}
@@ -0,0 +1,25 @@
package com.restcountries.domain.v4;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Ethnicity {
private String name;
private Double percentage;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Double getPercentage() {
return percentage;
}
public void setPercentage(Double percentage) {
this.percentage = percentage;
}
}
@@ -0,0 +1,25 @@
package com.restcountries.domain.v4;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class GDP {
private Long total;
private Long perCapita;
public Long getTotal() {
return total;
}
public void setTotal(Long total) {
this.total = total;
}
public Long getPerCapita() {
return perCapita;
}
public void setPerCapita(Long perCapita) {
this.perCapita = perCapita;
}
}
@@ -0,0 +1,25 @@
package com.restcountries.domain.v4;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Geolocation {
private Double latitude;
private Double longitude;
public Double getLatitude() {
return latitude;
}
public void setLatitude(Double latitude) {
this.latitude = latitude;
}
public Double getLongitude() {
return longitude;
}
public void setLongitude(Double longitude) {
this.longitude = longitude;
}
}
@@ -0,0 +1,25 @@
package com.restcountries.domain.v4;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Gini {
private String year;
private Double value;
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
public Double getValue() {
return value;
}
public void setValue(Double value) {
this.value = value;
}
}
@@ -0,0 +1,27 @@
package com.restcountries.domain.v4;
import io.micronaut.serde.annotation.Serdeable;
import java.util.List;
@Serdeable.Serializable
public class Government {
private String type;
private List<Leader> leaders;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List<Leader> getLeaders() {
return leaders;
}
public void setLeaders(List<Leader> leaders) {
this.leaders = leaders;
}
}
@@ -0,0 +1,43 @@
package com.restcountries.domain.v4;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Language {
private String iso639_1;
private String iso639_2;
private String name;
private String nativeName;
public String getIso639_1() {
return iso639_1;
}
public void setIso639_1(String iso639_1) {
this.iso639_1 = iso639_1;
}
public String getIso639_2() {
return iso639_2;
}
public void setIso639_2(String iso639_2) {
this.iso639_2 = iso639_2;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNativeName() {
return nativeName;
}
public void setNativeName(String nativeName) {
this.nativeName = nativeName;
}
}
@@ -0,0 +1,25 @@
package com.restcountries.domain.v4;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Leader {
private String title;
private String name;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,36 @@
package com.restcountries.domain.v4;
import io.micronaut.serde.annotation.Serdeable;
import java.util.List;
@Serdeable.Serializable
public class Name {
private String common;
private String official;
private List<NativeName> nativeName;
public String getCommon() {
return common;
}
public void setCommon(String common) {
this.common = common;
}
public String getOfficial() {
return official;
}
public void setOfficial(String official) {
this.official = official;
}
public List<NativeName> getNativeName() {
return nativeName;
}
public void setNativeName(List<NativeName> nativeName) {
this.nativeName = nativeName;
}
}
@@ -0,0 +1,34 @@
package com.restcountries.domain.v4;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class NativeName {
private String lang;
private String official;
private String common;
public String getLang() {
return lang;
}
public void setLang(String lang) {
this.lang = lang;
}
public String getOfficial() {
return official;
}
public void setOfficial(String official) {
this.official = official;
}
public String getCommon() {
return common;
}
public void setCommon(String common) {
this.common = common;
}
}
@@ -0,0 +1,40 @@
package com.restcountries.domain.v4;
import io.micronaut.serde.annotation.Serdeable;
import java.util.ArrayList;
import java.util.List;
@Serdeable.Serializable
public class RegionalBloc {
private String acronym;
private String name;
private List<String> otherNames;
public String getAcronym() {
return acronym;
}
public void setAcronym(String acronym) {
this.acronym = acronym;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getOtherNames() {
if (otherNames == null) {
otherNames = new ArrayList<>();
}
return otherNames;
}
public void setOtherNames(List<String> otherNames) {
this.otherNames = otherNames;
}
}
@@ -0,0 +1,34 @@
package com.restcountries.domain.v4;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Religion {
private String name;
private Long population;
private Double percentage;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getPopulation() {
return population;
}
public void setPopulation(Long population) {
this.population = population;
}
public Double getPercentage() {
return percentage;
}
public void setPercentage(Double percentage) {
this.percentage = percentage;
}
}
@@ -0,0 +1,34 @@
package com.restcountries.domain.v4;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable.Serializable
public class Translation {
private String lang;
private String official;
private String common;
public String getLang() {
return lang;
}
public void setLang(String lang) {
this.lang = lang;
}
public String getOfficial() {
return official;
}
public void setOfficial(String official) {
this.official = official;
}
public String getCommon() {
return common;
}
public void setCommon(String common) {
this.common = common;
}
}
@@ -0,0 +1,174 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package com.restcountries.service.v2;
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import com.restcountries.domain.BaseCountry;
import com.restcountries.domain.ICountryRestSymbols;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.text.Normalizer;
import java.util.ArrayList;
import java.util.List;
public class CountryServiceBaseV2 {
protected <T extends BaseCountry> T getByAlpha(String alpha, List<T> countries) {
int alphaLength = alpha.length();
for (T country : countries) {
if (alphaLength == 2) {
if (country.getAlpha2Code().equalsIgnoreCase(alpha)) {
return country;
}
} else if (alphaLength == 3 && country.getAlpha3Code().equalsIgnoreCase(alpha)) {
return country;
}
}
return null;
}
protected List<? extends BaseCountry> getByCodeList(String codeList,
List<? extends BaseCountry> countries) {
List<BaseCountry> result = new ArrayList<>();
if (codeList == null) {
return result;
}
String[] codes = codeList.split(ICountryRestSymbols.COLON);
for (String code : codes) {
BaseCountry country = getByAlpha(code, countries);
if (null != country && !result.contains(country)) {
result.add(country);
}
}
return result;
}
protected List<? extends BaseCountry> getByName(String name, boolean fullText,
List<? extends BaseCountry> countries) {
if (fullText) {
return fulltextSearch(name, countries);
} else {
return substringSearch(name, countries);
}
}
protected List<? extends BaseCountry> getByCallingCode(String callingCode,
List<? extends BaseCountry> countries) {
List<BaseCountry> result = new ArrayList<>();
for (BaseCountry country : countries) {
for (String c : country.getCallingCodes()) {
if (c.equals(callingCode)) {
result.add(country);
}
}
}
return result;
}
protected List<? extends BaseCountry> getByCapital(String capital,
List<? extends BaseCountry> countries) {
List<BaseCountry> result = new ArrayList<>();
for (BaseCountry country : countries) {
if (normalize(country.getCapital().toLowerCase()).contains(
normalize(capital.toLowerCase()))) {
result.add(country);
}
}
return result;
}
protected List<? extends BaseCountry> getByRegion(String region,
List<? extends BaseCountry> countries) {
List<BaseCountry> result = new ArrayList<>();
for (BaseCountry country : countries) {
if (country.getRegion().equalsIgnoreCase(region)) {
result.add(country);
}
}
return result;
}
protected List<? extends BaseCountry> getBySubregion(String subregion,
List<? extends BaseCountry> countries) {
List<BaseCountry> result = new ArrayList<>();
for (BaseCountry country : countries) {
if (country.getSubregion().equalsIgnoreCase(subregion)) {
result.add(country);
}
}
return result;
}
private List<? extends BaseCountry> fulltextSearch(String name,
List<? extends BaseCountry> countries) {
// Using 2 different 'for' loops to give priority to 'name' matches over alternative spellings
List<BaseCountry> result = new ArrayList<>();
for (BaseCountry country : countries) {
if (normalize(country.getName().toLowerCase()).equals(normalize(name.toLowerCase()))) {
result.add(country);
}
}
for (BaseCountry country : countries) {
for (String alternative : country.getAltSpellings()) {
if (normalize(alternative.toLowerCase()).equals(normalize(name.toLowerCase()))
&& !result.contains(country)) {
result.add(country);
}
}
}
return result;
}
private List<? extends BaseCountry> substringSearch(String name,
List<? extends BaseCountry> countries) {
// Using 2 different 'for' loops to give priority to 'name' matches over alternative spellings
List<BaseCountry> result = new ArrayList<>();
for (BaseCountry country : countries) {
if (normalize(country.getName().toLowerCase()).contains(normalize(name.toLowerCase()))) {
result.add(country);
}
}
for (BaseCountry country : countries) {
for (String alternative : country.getAltSpellings()) {
if (normalize(alternative.toLowerCase()).contains(normalize(name.toLowerCase()))
&& !result.contains(country)) {
result.add(country);
}
}
}
return result;
}
protected String normalize(String string) {
return Normalizer.normalize(string, Normalizer.Form.NFD)
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
protected List<? extends BaseCountry> loadJson(String filename,
Class<? extends BaseCountry> clazz) {
List<BaseCountry> countries = new ArrayList<>();
InputStream is = CountryServiceBaseV2.class.getClassLoader().getResourceAsStream(filename);
var gson = new Gson();
JsonReader reader;
try {
assert is != null;
reader = new JsonReader(new InputStreamReader(is, StandardCharsets.UTF_8));
reader.beginArray();
while (reader.hasNext()) {
BaseCountry country = gson.fromJson(reader, clazz);
countries.add(country);
}
} catch (Exception e) {
e.printStackTrace();
}
return countries;
}
}
@@ -1,19 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package dev.amatos.restcountries.service.v2;
package com.restcountries.service.v2;
import com.restcountries.domain.v2.Country;
import com.restcountries.domain.v2.Currency;
import com.restcountries.domain.v2.RegionalBloc;
import dev.amatos.restcountries.domain.v2.Country;
import dev.amatos.restcountries.domain.v2.Currency;
import dev.amatos.restcountries.domain.v2.Language;
import dev.amatos.restcountries.domain.v2.RegionalBloc;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
public class CountryServiceV2 extends CountryServiceBaseV2 {
private static final Logger LOG = Logger.getLogger(CountryServiceV2.class);
private static List<Country> countries;
@@ -58,20 +56,20 @@ public class CountryServiceV2 extends CountryServiceBaseV2 {
}
@SuppressWarnings("unchecked")
public List<Country> getByContinent(String region) {
return (List<Country>) super.getByContinent(region, countries);
public List<Country> getByRegion(String region) {
return (List<Country>) super.getByRegion(region, countries);
}
@SuppressWarnings("unchecked")
public List<Country> getByRegion(String subregion) {
return (List<Country>) super.getByRegion(subregion, countries);
public List<Country> getBySubregion(String subregion) {
return (List<Country>) super.getBySubregion(subregion, countries);
}
public List<Country> getByCurrency(String currency) {
List<Country> result = new ArrayList<>();
for (Country country : countries) {
for (Currency curr : country.getCurrencies()) {
if (curr.getCode() != null && currency.toLowerCase().equals(curr.getCode().toLowerCase())) {
if (curr.getCode() != null && currency.equalsIgnoreCase(curr.getCode())) {
result.add(country);
}
}
@@ -82,25 +80,29 @@ public class CountryServiceV2 extends CountryServiceBaseV2 {
public List<Country> getByLanguage(String language) {
List<Country> result = new ArrayList<>();
if (language.length() == 2) {
for (Country country : countries) {
for (Language lang : country.getLanguages()) {
if (language.toLowerCase().equals(lang.getIso639_1())) {
result.add(country);
}
}
}
checkLanguageAndAddIfIso1Matches(language, result);
} else if (language.length() == 3) {
for (Country country : countries) {
for (Language lang : country.getLanguages()) {
if (language.toLowerCase().equals(lang.getIso639_2())) {
result.add(country);
}
}
}
checkLanguageAndAddIfIso2Matches(language, result);
}
return result;
}
private void checkLanguageAndAddIfIso2Matches(String language, List<Country> result) {
countries.forEach(country -> country.getLanguages().forEach(lang -> {
if (language.toLowerCase().equals(lang.getIso639_2())) {
result.add(country);
}
}));
}
private void checkLanguageAndAddIfIso1Matches(String language, List<Country> result) {
countries.forEach(country -> country.getLanguages().forEach(lang -> {
if (language.toLowerCase().equals(lang.getIso639_1())) {
result.add(country);
}
}));
}
public List<Country> getByDemonym(String demonym) {
List<Country> result = new ArrayList<>();
for (Country country : countries) {
@@ -128,8 +130,8 @@ public class CountryServiceV2 extends CountryServiceBaseV2 {
private boolean getRegionalBlockMatch(String acronym, List<String> otherAcronym,
String regionalBlock) {
return acronym != null && otherAcronym != null && ((acronym.equalsIgnoreCase(regionalBlock)
|| otherAcronym.contains(regionalBlock)));
return acronym != null && otherAcronym != null && (acronym.equalsIgnoreCase(regionalBlock)
|| otherAcronym.contains(regionalBlock));
}
@SuppressWarnings("unchecked")
@@ -1,12 +1,13 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package dev.amatos.restcountries.service.v3;
package com.restcountries.service.v3;
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import dev.amatos.restcountries.domain.ICountryRestSymbols;
import dev.amatos.restcountries.domain.base.BaseCountry;
import com.restcountries.domain.ICountryRestSymbols;
import com.restcountries.domain.base.BaseCountry;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
@@ -68,12 +69,11 @@ public class CountryServiceBaseV3 {
// Using 2 different 'for' loops to give priority to 'name' matches over alternative spellings
Set<BaseCountry> result = new HashSet<>();
for (var country : countries) {
if (name.toLowerCase().contains(country.getName().getCommon().toLowerCase()) ||
name.toLowerCase().contains(country.getName().getOfficial().toLowerCase())) {
if(country.getName().getCommon().toLowerCase().contains(name.toLowerCase()) ||
country.getName().getOfficial().toLowerCase().contains(name.toLowerCase())
) {
result.add(country);
}
}
for (var country : countries) {
for (String alternative : country.getAltSpellings()) {
if (alternative.toLowerCase().contains(name.toLowerCase())) {
result.add(country);
@@ -1,9 +1,10 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package dev.amatos.restcountries.service.v3;
package com.restcountries.service.v3;
import com.restcountries.domain.v3.Country;
import dev.amatos.restcountries.domain.v3.Country;
import java.text.Normalizer;
import java.util.HashSet;
import java.util.Set;
@@ -22,7 +23,7 @@ public class CountryServiceV3 extends CountryServiceBaseV3 {
}
public static CountryServiceV3 getInstance() {
return CountryServiceV3.InstanceHolder.INSTANCE;
return InstanceHolder.INSTANCE;
}
public Set<Country> getAll() {
@@ -77,12 +78,14 @@ public class CountryServiceV3 extends CountryServiceBaseV3 {
return result;
}
@Override
protected String normalize(String string) {
return Normalizer.normalize(string, Normalizer.Form.NFD)
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
private void initialize() {
countries = (Set<Country>) super.loadJson("countriesV3.json", Country.class);
var c = (Set<Country>) super.loadJson("countriesV3.json", Country.class);
countries = c;
}
}
@@ -1,13 +1,15 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package dev.amatos.restcountries.service.v3.v31;
package com.restcountries.service.v3.v31;
import com.restcountries.domain.v3.v31.Country;
import com.restcountries.service.v3.CountryServiceBaseV3;
import dev.amatos.restcountries.domain.v3.v31.Country;
import dev.amatos.restcountries.service.v3.CountryServiceBaseV3;
import java.text.Normalizer;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
public class CountryServiceV31 extends CountryServiceBaseV3 {
@@ -23,7 +25,7 @@ public class CountryServiceV31 extends CountryServiceBaseV3 {
}
public static CountryServiceV31 getInstance() {
return CountryServiceV31.InstanceHolder.INSTANCE;
return InstanceHolder.INSTANCE;
}
public Set<Country> getAll() {
@@ -78,6 +80,14 @@ public class CountryServiceV31 extends CountryServiceBaseV3 {
return result;
}
public Set<Country> getIndependent(boolean status) {
return countries.stream().filter(country -> {
var independent = Boolean.TRUE.equals(country.getIndependent());
return independent == status;
}).collect(Collectors.toSet());
}
@Override
protected String normalize(String string) {
return Normalizer.normalize(string, Normalizer.Form.NFD)
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
@@ -0,0 +1,198 @@
package com.restcountries.service.v4;
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import com.restcountries.domain.ICountryRestSymbols;
import com.restcountries.domain.v4.Country;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.text.Normalizer;
import java.util.HashSet;
import java.util.Set;
public class CountryServiceBaseV4 {
protected Set<Country> getByAlpha(String alpha, Set<Country> countries) {
var result = new HashSet<Country>();
for (var country : countries) {
if ((country.getCca2() != null && country.getCca2().equalsIgnoreCase(alpha)) ||
(country.getCcn3() != null && country.getCcn3().equalsIgnoreCase(alpha)) ||
(country.getCca3() != null && country.getCca3().equalsIgnoreCase(alpha)) ||
(country.getCioc() != null && country.getCioc().equalsIgnoreCase(alpha))
) {
result.add(country);
}
}
return result;
}
protected Set<Country> getByCodeList(String codeList, Set<Country> countries) {
Set<Country> result = new HashSet<>();
if (codeList == null) {
return result;
}
String[] codes = codeList.split(ICountryRestSymbols.COLON);
for (String code : codes) {
result.addAll(getByAlpha(code, countries));
}
return result;
}
protected Set<Country> getByName(String name, boolean fullText, Set<Country> countries) {
if (fullText) {
return fulltextSearch(name, countries);
} else {
return substringSearch(name, countries);
}
}
private Set<Country> fulltextSearch(String name, Set<Country> countries) {
Set<Country> result = new HashSet<>();
for (var country : countries) {
if (name.equalsIgnoreCase(country.getName().getCommon()) ||
name.equalsIgnoreCase(country.getName().getOfficial())) {
result.add(country);
return result;
}
}
return result;
}
private Set<Country> substringSearch(String name, Set<Country> countries) {
Set<Country> result = new HashSet<>();
for (var country : countries) {
if (country.getName().getCommon().toLowerCase().contains(name.toLowerCase()) ||
country.getName().getOfficial().toLowerCase().contains(name.toLowerCase())) {
result.add(country);
}
for (String alternative : country.getAltSpellings()) {
if (alternative.toLowerCase().contains(name.toLowerCase())) {
result.add(country);
}
}
}
return result;
}
protected Set<Country> getByCurrency(String currency, Set<Country> countries) {
Set<Country> result = new HashSet<>();
for (var country : countries) {
if (country.getCurrencies() != null) {
for (var c : country.getCurrencies()) {
if ((c.getCode() != null && c.getCode().equalsIgnoreCase(currency)) ||
(c.getName() != null && c.getName().toLowerCase().contains(currency.toLowerCase()))) {
result.add(country);
}
}
}
}
return result;
}
protected Set<Country> getByCapital(String capital, Set<Country> countries) {
Set<Country> result = new HashSet<>();
for (var country : countries) {
if (country.getCapital() != null) {
for (String countryCapital : country.getCapital()) {
if (normalize(countryCapital.toLowerCase()).contains(normalize(capital.toLowerCase()))) {
result.add(country);
}
}
}
}
return result;
}
protected Set<Country> getByRegion(String region, Set<Country> countries) {
Set<Country> result = new HashSet<>();
for (var country : countries) {
if ((country.getRegion() != null && country.getRegion().toLowerCase().contains(region.toLowerCase())) ||
(country.getSubregion() != null && country.getSubregion().equalsIgnoreCase(region))) {
result.add(country);
}
}
return result;
}
protected Set<Country> getBySubregion(String subregion, Set<Country> countries) {
Set<Country> result = new HashSet<>();
for (var country : countries) {
if (country.getSubregion() != null &&
(country.getSubregion().toLowerCase().contains(subregion.toLowerCase()) ||
country.getSubregion().equalsIgnoreCase(subregion))) {
result.add(country);
}
}
return result;
}
protected Set<Country> getByLanguage(String language, Set<Country> countries) {
Set<Country> result = new HashSet<>();
for (var country : countries) {
if (country.getLanguages() != null) {
for (var lang : country.getLanguages()) {
if ((lang.getName() != null && lang.getName().equalsIgnoreCase(language)) ||
(lang.getIso639_1() != null && lang.getIso639_1().equalsIgnoreCase(language)) ||
(lang.getIso639_2() != null && lang.getIso639_2().equalsIgnoreCase(language))) {
result.add(country);
}
}
}
}
return result;
}
protected Set<Country> getByDemonym(String demonym, Set<Country> countries) {
Set<Country> result = new HashSet<>();
for (var country : countries) {
if (country.getDemonyms() != null) {
for (var d : country.getDemonyms()) {
if ((d.getMale() != null && d.getMale().toLowerCase().contains(demonym.toLowerCase())) ||
(d.getFemale() != null && d.getFemale().toLowerCase().contains(demonym.toLowerCase()))) {
result.add(country);
}
}
}
}
return result;
}
protected Set<Country> getByTranslation(String translation, Set<Country> countries) {
Set<Country> result = new HashSet<>();
for (var country : countries) {
if (country.getTranslations() != null) {
for (var t : country.getTranslations()) {
if ((t.getOfficial() != null && t.getOfficial().toLowerCase().contains(translation.toLowerCase())) ||
(t.getCommon() != null && t.getCommon().toLowerCase().contains(translation.toLowerCase()))) {
result.add(country);
}
}
}
}
return result;
}
protected String normalize(String string) {
return Normalizer.normalize(string, Normalizer.Form.NFD)
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
protected Set<Country> loadJson(String filename) {
Set<Country> countries = new HashSet<>();
InputStream is = CountryServiceBaseV4.class.getClassLoader().getResourceAsStream(filename);
Gson gson = new Gson();
try {
JsonReader reader = new JsonReader(new InputStreamReader(is, StandardCharsets.UTF_8));
reader.beginArray();
while (reader.hasNext()) {
Country country = gson.fromJson(reader, Country.class);
countries.add(country);
}
} catch (Exception e) {
e.printStackTrace();
}
return countries;
}
}
@@ -0,0 +1,86 @@
package com.restcountries.service.v4;
import com.restcountries.domain.v4.Country;
import java.text.Normalizer;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
public class CountryServiceV4 extends CountryServiceBaseV4 {
private static Set<Country> countries;
private CountryServiceV4() {
initialize();
}
private static class InstanceHolder {
private static final CountryServiceV4 INSTANCE = new CountryServiceV4();
}
public static CountryServiceV4 getInstance() {
return InstanceHolder.INSTANCE;
}
public Set<Country> getAll() {
return countries;
}
public Set<Country> getByAlpha(String alpha) {
return super.getByAlpha(alpha, countries);
}
public Set<Country> getByName(String name, boolean isFullText) {
return super.getByName(name, isFullText, countries);
}
public Set<Country> getByCurrency(String currency) {
return super.getByCurrency(currency, countries);
}
public Set<Country> getByCodeList(String codeList) {
return super.getByCodeList(codeList, countries);
}
public Set<Country> getByCapital(String capital) {
return super.getByCapital(capital, countries);
}
public Set<Country> getByRegion(String region) {
return super.getByRegion(region, countries);
}
public Set<Country> getBySubregion(String subregion) {
return super.getBySubregion(subregion, countries);
}
public Set<Country> getByLanguage(String language) {
return super.getByLanguage(language, countries);
}
public Set<Country> getByDemonym(String demonym) {
return super.getByDemonym(demonym, countries);
}
public Set<Country> getByTranslation(String translation) {
return super.getByTranslation(translation, countries);
}
public Set<Country> getIndependent(boolean status) {
return countries.stream().filter(country -> {
var independent = Boolean.TRUE.equals(country.getIndependent());
return independent == status;
}).collect(Collectors.toSet());
}
@Override
protected String normalize(String string) {
return Normalizer.normalize(string, Normalizer.Form.NFD)
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
private void initialize() {
countries = super.loadJson("countriesV4.json");
}
}
@@ -0,0 +1,6 @@
package com.restcountries.utils;
public class Constants {
public static final String CACHE_CONTROL_VALUE="public, immutable, max-age=31556926";
}
@@ -1,297 +0,0 @@
package dev.amatos.restcountries.controller;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import dev.amatos.restcountries.domain.ICountryRestSymbols;
import dev.amatos.restcountries.domain.ResponseEntity;
import dev.amatos.restcountries.domain.v3.Country;
import dev.amatos.restcountries.service.v3.CountryServiceV3;
import io.micronaut.http.HttpResponse;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.annotation.PathVariable;
import io.micronaut.http.annotation.QueryValue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
@Controller("v3/")
public class CountryControllerV3 {
@Get(uri = "all", produces = MediaType.APPLICATION_JSON)
public Object getAllCountries(@QueryValue("fields") Optional<String> fields) {
var countries = CountryServiceV3.getInstance().getAll();
return checkFieldsAndParseCountries(fields, countries);
}
private Object checkFieldsAndParseCountries(Optional<String> fields,
Set<Country> countries) {
if (fields.isPresent()) {
return parsedCountries(countries, fields.get());
} else {
return parsedCountries(countries, null);
}
}
@Get("alpha/{alphacode}")
public Object getByAlpha(@PathVariable("alphacode") String alpha,
@QueryValue("fields") Optional<String> fields) {
if (alpha.contains("codes")) {
alpha = alpha.replace("codes=", "");
}
if (isEmpty(alpha) || alpha.length() < 2 || alpha.length() > 3) {
return HttpResponse.badRequest(getResponse(Response.Status.BAD_REQUEST));
}
var country = CountryServiceV3.getInstance().getByAlpha(alpha);
if (country != null) {
return checkFieldsAndParseCountry(country, fields);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
}
private Object checkFieldsAndParseCountry(Set<Country> countries, Optional<String> fields) {
if (fields.isPresent()) {
return parsedCountry(countries, fields.get());
} else {
return parsedCountry(countries, null);
}
}
@Get("alpha/")
public Object getByAlphaList(@QueryParam("codes") String codes,
@QueryParam("fields") Optional<String> fields) {
if (isEmpty(codes) || codes.length() < 2 || (codes.length() > 3 && !codes.contains(","))) {
return HttpResponse.badRequest(getResponse(Response.Status.BAD_REQUEST));
}
try {
var countries = CountryServiceV3.getInstance().getByCodeList(codes);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(getResponse(Response.Status.INTERNAL_SERVER_ERROR));
}
}
@Get("currency/{currency}")
public Object getByCurrency(@PathVariable("currency") String currency,
@QueryParam("fields") Optional<String> fields) {
if (isEmpty(currency)) {
return getResponse(Response.Status.BAD_REQUEST);
}
try {
var countries = CountryServiceV3.getInstance().getByCurrency(currency);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(getResponse(Response.Status.INTERNAL_SERVER_ERROR));
}
}
@Get("name/{name}")
public Object getByName(@PathVariable("name") String name,
@QueryParam("fullText") Optional<Boolean> fullText,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV3.getInstance()
.getByName(name, fullText.orElse(false));
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("capital/{capital}")
public Object getByCapital(@PathVariable("capital") String capital,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV3.getInstance().getByCapital(capital);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("region/{region}")
public Object getByContinent(@PathVariable("region") String region,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV3.getInstance().getByRegion(region);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("subregion/{subregion}")
public Object getBySubRegion(@PathVariable("subregion") String subregion,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV3.getInstance().getBySubregion(subregion);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("lang/{lang}")
public Object getByLanguage(@PathVariable("lang") String language,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV3.getInstance().getByLanguage(language);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("demonym/{demonym}")
public Object getByDemonym(@PathVariable("demonym") String demonym,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV3.getInstance().getByDemonym(demonym);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("translation/{translation}")
public Object getByTranslation(@PathVariable("translation") String translation,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV3.getInstance().getByTranslation(translation);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
private Object parsedCountries(Set<Country> countries, String excludedFields) {
if (excludedFields == null || excludedFields.isEmpty()) {
return countries;
} else {
return getCountriesJson(countries,
Arrays.asList(excludedFields.split(ICountryRestSymbols.COLON)));
}
}
private String getCountriesJson(Set<Country> countries, List<String> fields) {
var gson = new Gson();
var parser = new JsonParser();
var jsonArray = parser.parse(gson.toJson(countries)).getAsJsonArray();
var resultArray = new JsonArray();
jsonArray.forEach(element -> {
var jsonObject = (JsonObject) element;
var excludedFields = getExcludedFields(fields);
excludedFields.forEach(jsonObject::remove);
resultArray.add(jsonObject);
});
return resultArray.toString();
}
private List<String> getExcludedFields(List<String> fields) {
List<String> excludedFields = new ArrayList<>(Arrays.asList(COUNTRY_FIELDS));
excludedFields.removeAll(fields);
return excludedFields;
}
private Object getResponse(Response.Status status) {
var gson = new Gson();
return Response
.status(status)
.entity(gson.toJson(new ResponseEntity(status.getStatusCode(),
status.getReasonPhrase())))
.build()
.getEntity();
}
private Object parsedCountry(Set<Country> countries, String fields) {
if (fields == null || fields.isEmpty()) {
return countries;
} else {
StringBuilder result = new StringBuilder();
countries.forEach(country -> result.append(
getCountryJson(country, Arrays.asList(fields.split(ICountryRestSymbols.COLON)))));
return result;
}
}
private String getCountryJson(Country country, List<String> fields) {
var gson = new Gson();
var parser = new JsonParser();
var jsonObject = parser.parse(gson.toJson(country)).getAsJsonObject();
List<String> excludedFields = getExcludedFields(fields);
excludedFields.forEach(jsonObject::remove);
return jsonObject.toString();
}
private static final String[] COUNTRY_FIELDS = new String[]{
"name",
"tld",
"cca2",
"ccn3",
"cca3",
"cioc",
"independent",
"status",
"unMember",
"currencies",
"idd",
"capital",
"altSpellings",
"region",
"subregion",
"languages",
"translations",
"latlng",
"landlocked",
"borders",
"area",
"flags",
"demonyms",
"population",
"flags",
"flag",
"maps"
};
private boolean isEmpty(String value) {
return value == null || value.isEmpty();
}
}
@@ -1,296 +0,0 @@
package dev.amatos.restcountries.controller;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import dev.amatos.restcountries.domain.ICountryRestSymbols;
import dev.amatos.restcountries.domain.ResponseEntity;
import dev.amatos.restcountries.domain.v3.v31.Country;
import dev.amatos.restcountries.service.v3.v31.CountryServiceV31;
import io.micronaut.http.HttpResponse;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.annotation.PathVariable;
import io.micronaut.http.annotation.QueryValue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
@Controller("v3.1/")
public class CountryControllerV31 {
@Get(uri = "all", produces = MediaType.APPLICATION_JSON)
public Object getAllCountries(@QueryValue("fields") Optional<String> fields) {
var countries = CountryServiceV31.getInstance().getAll();
return checkFieldsAndParseCountries(fields, countries);
}
private Object checkFieldsAndParseCountries(Optional<String> fields,
Set<Country> countries) {
if (fields.isPresent()) {
return parsedCountries(countries, fields.get());
} else {
return parsedCountries(countries, null);
}
}
@Get("alpha/{alphacode}")
public Object getByAlpha(@PathVariable("alphacode") String alpha,
@QueryValue("fields") Optional<String> fields) {
if (alpha.contains("codes")) {
alpha = alpha.replace("codes=", "");
}
if (isEmpty(alpha) || alpha.length() < 2 || alpha.length() > 3) {
return HttpResponse.badRequest(getResponse(Response.Status.BAD_REQUEST));
}
var country = CountryServiceV31.getInstance().getByAlpha(alpha);
if (country != null) {
return checkFieldsAndParseCountry(country, fields);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
}
private Object checkFieldsAndParseCountry(Set<Country> countries, Optional<String> fields) {
if (fields.isPresent()) {
return parsedCountry(countries, fields.get());
} else {
return parsedCountry(countries, null);
}
}
@Get("alpha/")
public Object getByAlphaList(@QueryParam("codes") String codes,
@QueryParam("fields") Optional<String> fields) {
if (isEmpty(codes) || codes.length() < 2 || (codes.length() > 3 && !codes.contains(","))) {
return HttpResponse.badRequest(getResponse(Response.Status.BAD_REQUEST));
}
try {
var countries = CountryServiceV31.getInstance().getByCodeList(codes);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(getResponse(Response.Status.INTERNAL_SERVER_ERROR));
}
}
@Get("currency/{currency}")
public Object getByCurrency(@PathVariable("currency") String currency,
@QueryParam("fields") Optional<String> fields) {
if (isEmpty(currency)) {
return getResponse(Response.Status.BAD_REQUEST);
}
try {
var countries = CountryServiceV31.getInstance().getByCurrency(currency);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(getResponse(Response.Status.INTERNAL_SERVER_ERROR));
}
}
@Get("name/{name}")
public Object getByName(@PathVariable("name") String name,
@QueryParam("fullText") Optional<Boolean> fullText,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV31.getInstance()
.getByName(name, fullText.orElse(false));
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("capital/{capital}")
public Object getByCapital(@PathVariable("capital") String capital,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV31.getInstance().getByCapital(capital);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("region/{region}")
public Object getByContinent(@PathVariable("region") String region,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV31.getInstance().getByRegion(region);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("subregion/{subregion}")
public Object getBySubRegion(@PathVariable("subregion") String subregion,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV31.getInstance().getBySubregion(subregion);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("lang/{lang}")
public Object getByLanguage(@PathVariable("lang") String language,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV31.getInstance().getByLanguage(language);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("demonym/{demonym}")
public Object getByDemonym(@PathVariable("demonym") String demonym,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV31.getInstance().getByDemonym(demonym);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Get("translation/{translation}")
public Object getByTranslation(@PathVariable("translation") String translation,
@QueryParam("fields") Optional<String> fields) {
try {
var countries = CountryServiceV31.getInstance().getByTranslation(translation);
if (!countries.isEmpty()) {
return checkFieldsAndParseCountries(fields, countries);
}
return HttpResponse.notFound(getResponse(Response.Status.NOT_FOUND));
} catch (Exception e) {
return HttpResponse.serverError(Response.Status.INTERNAL_SERVER_ERROR);
}
}
private Object parsedCountries(Set<Country> countries, String excludedFields) {
if (excludedFields == null || excludedFields.isEmpty()) {
return countries;
} else {
return getCountriesJson(countries,
Arrays.asList(excludedFields.split(ICountryRestSymbols.COLON)));
}
}
private String getCountriesJson(Set<Country> countries, List<String> fields) {
var gson = new Gson();
var parser = new JsonParser();
var jsonArray = parser.parse(gson.toJson(countries)).getAsJsonArray();
var resultArray = new JsonArray();
jsonArray.forEach(element -> {
var jsonObject = (JsonObject) element;
var excludedFields = getExcludedFields(fields);
excludedFields.forEach(jsonObject::remove);
resultArray.add(jsonObject);
});
return resultArray.toString();
}
private List<String> getExcludedFields(List<String> fields) {
List<String> excludedFields = new ArrayList<>(Arrays.asList(COUNTRY_FIELDS));
excludedFields.removeAll(fields);
return excludedFields;
}
private Object getResponse(Response.Status status) {
var gson = new Gson();
return Response
.status(status)
.entity(gson.toJson(new ResponseEntity(status.getStatusCode(),
status.getReasonPhrase())))
.build()
.getEntity();
}
private Object parsedCountry(Set<Country> countries, String fields) {
if (fields == null || fields.isEmpty()) {
return countries;
} else {
StringBuilder result = new StringBuilder();
countries.forEach(country -> result.append(
getCountryJson(country, Arrays.asList(fields.split(ICountryRestSymbols.COLON)))));
return result;
}
}
private String getCountryJson(Country country, List<String> fields) {
var gson = new Gson();
var parser = new JsonParser();
var jsonObject = parser.parse(gson.toJson(country)).getAsJsonObject();
List<String> excludedFields = getExcludedFields(fields);
excludedFields.forEach(jsonObject::remove);
return jsonObject.toString();
}
private static final String[] COUNTRY_FIELDS = new String[]{
"name",
"tld",
"cca2",
"ccn3",
"cca3",
"cioc",
"independent",
"status",
"unMember",
"currencies",
"idd",
"capital",
"altSpellings",
"region",
"subregion",
"languages",
"translations",
"latlng",
"landlocked",
"borders",
"area",
"flags",
"demonyms",
"flag",
"population",
"maps"
};
private boolean isEmpty(String value) {
return value == null || value.isEmpty();
}
}
@@ -1,18 +0,0 @@
package dev.amatos.restcountries.domain.v3.v31;
import dev.amatos.restcountries.domain.base.BaseCountry;
import java.util.Map;
public class Country extends BaseCountry {
private Map<String, String> flags;
public Map<String, String> getFlags() {
return flags;
}
public void setFlags(Map<String, String> flags) {
this.flags = flags;
}
}
@@ -1,162 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package dev.amatos.restcountries.service.v2;
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import dev.amatos.restcountries.domain.BaseCountry;
import dev.amatos.restcountries.domain.ICountryRestSymbols;
import org.apache.log4j.Logger;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.text.Normalizer;
import java.util.ArrayList;
import java.util.List;
public class CountryServiceBaseV2 {
private static final Logger LOG = Logger.getLogger(CountryServiceBaseV2.class);
protected <T extends BaseCountry> T getByAlpha(String alpha, List<T> countries) {
int alphaLength = alpha.length();
for (T country : countries) {
if (alphaLength == 2) {
if (country.getAlpha2Code().equalsIgnoreCase(alpha)) {
return country;
}
} else if (alphaLength == 3 && country.getAlpha3Code().equalsIgnoreCase(alpha)) {
return country;
}
}
return null;
}
protected List<? extends BaseCountry> getByCodeList(String codeList, List<? extends BaseCountry> countries) {
List<BaseCountry> result = new ArrayList<>();
if (codeList == null) return result;
String[] codes = codeList.split(ICountryRestSymbols.COLON);
for (String code : codes) {
BaseCountry country = getByAlpha(code, countries);
if (!result.contains(country))
result.add(country);
}
return result;
}
protected List<? extends BaseCountry> getByName(String name, boolean fullText, List<? extends BaseCountry> countries) {
if (fullText) {
return fulltextSearch(name, countries);
} else {
return substringSearch(name, countries);
}
}
protected List<? extends BaseCountry> getByCallingCode(String callingCode, List<? extends BaseCountry> countries) {
List<BaseCountry> result = new ArrayList<>();
for (BaseCountry country : countries) {
for (String c : country.getCallingCodes()) {
if (c.equals(callingCode))
result.add(country);
}
}
return result;
}
protected List<? extends BaseCountry> getByCapital(String capital, List<? extends BaseCountry> countries) {
List<BaseCountry> result = new ArrayList<>();
for (BaseCountry country : countries) {
if (normalize(country.getCapital().toLowerCase()).contains(normalize(capital.toLowerCase()))) {
result.add(country);
}
}
return result;
}
protected List<? extends BaseCountry> getByContinent(String region, List<? extends BaseCountry> countries) {
List<BaseCountry> result = new ArrayList<>();
for (BaseCountry country : countries) {
if (country.getRegion().equalsIgnoreCase(region)) {
result.add(country);
}
}
return result;
}
protected List<? extends BaseCountry> getByRegion(String subregion, List<? extends BaseCountry> countries) {
List<BaseCountry> result = new ArrayList<>();
for (BaseCountry country : countries) {
if (country.getSubregion().equalsIgnoreCase(subregion)) {
result.add(country);
}
}
return result;
}
private List<? extends BaseCountry> fulltextSearch(String name, List<? extends BaseCountry> countries) {
// Using 2 different 'for' loops to give priority to 'name' matches over alternative spellings
List<BaseCountry> result = new ArrayList<>();
for (BaseCountry country : countries) {
if (normalize(country.getName().toLowerCase()).equals(normalize(name.toLowerCase()))) {
result.add(country);
}
}
for (BaseCountry country : countries) {
for (String alternative : country.getAltSpellings()) {
if (normalize(alternative.toLowerCase()).equals(normalize(name.toLowerCase()))
&& !result.contains(country)) {
result.add(country);
}
}
}
return result;
}
private List<? extends BaseCountry> substringSearch(String name, List<? extends BaseCountry> countries) {
// Using 2 different 'for' loops to give priority to 'name' matches over alternative spellings
List<BaseCountry> result = new ArrayList<>();
for (BaseCountry country : countries) {
if (normalize(country.getName().toLowerCase()).contains(normalize(name.toLowerCase()))) {
result.add(country);
}
}
for (BaseCountry country : countries) {
for (String alternative : country.getAltSpellings()) {
if (normalize(alternative.toLowerCase()).contains(normalize(name.toLowerCase()))
&& !result.contains(country)) {
result.add(country);
}
}
}
return result;
}
protected String normalize(String string) {
return Normalizer.normalize(string, Normalizer.Form.NFD)
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
protected List<? extends BaseCountry> loadJson(String filename, Class<? extends BaseCountry> clazz) {
LOG.debug("Loading JSON " + filename);
List<BaseCountry> countries = new ArrayList<>();
InputStream is = CountryServiceBaseV2.class.getClassLoader().getResourceAsStream(filename);
var gson = new Gson();
JsonReader reader;
try {
assert is != null;
reader = new JsonReader(new InputStreamReader(is, StandardCharsets.UTF_8));
reader.beginArray();
while (reader.hasNext()) {
BaseCountry country = gson.fromJson(reader, clazz);
countries.add(country);
}
} catch (Exception e) {
e.printStackTrace();
LOG.error("Could not load JSON " + filename);
}
return countries;
}
}
+6 -2
View File
@@ -1,6 +1,7 @@
#Wed Mar 12 15:11:47 UTC 2025
micronaut:
application:
name: dev.amatos.restcountries
name=restcountries
router.static-resources.default:
enabled: true
paths: classpath:static
@@ -11,4 +12,7 @@ micronaut:
configurations:
web:
allowedMethods:
- GET
- GET
caches:
rate-limiter:
expire-after-access: 10m
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-1
View File
@@ -1,7 +1,6 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<withJansi>false</withJansi>
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
-9
View File
@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="900" height="600" viewBox="0 0 27 18">
<path d="M0,0H27V18H0z" fill="#4189dd"/>
<path d="M0,12H27v1H0v1H27v1H0z" fill="#f9d616"/>
<g fill="#fff" transform="translate(4,4)">
<path id="s" d="M0,-3 0.707107,-0.707107 3,0 0.707107,0.707107 0,3 -0.707107,0.707107 -3,0 -0.707107,-0.707107z"/>
<use xlink:href="#s" transform="scale(0.770376)" fill="#d21034"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 502 B

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 46 KiB

-23
View File
@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="450" height="300">
<rect width="450" height="300" fill="#000"/>
<rect width="450" height="150" fill="#ce1126"/>
<g fill="#f9d616">
<path d="M231.115,91.82A58.5,58.5 0 1,1 187.916,195.244L179.358,205.685A72,72 0 1,0 232.526,78.394z"/>
<g id="s3">
<path id="s" d="M302.62435,142.35494C303.12516,147.43953 303.12516,152.56101 302.62435,157.6456L287.69659,156.17534C288.10106,152.06855 288.10106,147.93196 287.69659,143.82518z"/>
<use xlink:href="#s" transform="rotate(22.5,225,150)"/>
<use xlink:href="#s" transform="rotate(45,225,150)"/>
</g>
<use xlink:href="#s3" transform="rotate(-67.5,225,150)"/>
<use xlink:href="#s3" transform="rotate(67.5,225,150)"/>
<path d="M199.32444,114.65618H250.67551L209.1325,144.84033 224.99998,96.000328 240.86746,144.84033z"/>
<path d="M287.87869,216.3146C291.71694,220.02891 296.88529,223.69038 300.6338,227.01716C304.38231,230.34392 307.25434,233.10958 309.57908,236.88884C312.98624,242.42773 309.16023,248.7008 303.85486,245.01872C300.98581,243.02751 299.18307,237.65214 294.78788,233.20395C291.53252,230.43267 288.96764,227.52745 280.78551,226.1257C280.39268,226.05841 280.27777,225.22842 280.58665,224.86618z"/>
<path fill="#000" d="M231.36058,197.84505 251.60791,209.8174 256.00949,226.89558 279.24991,225.13494 289.46162,213.16262 251.60791,186.9291 231.36058,197.84505z"/>
<path d="M279.66324,223.6894C253.62799,206.37539 237.07238,197.02622 212.12131,182.83938C202.31974,177.26634 187.0985,163.25747 199.1052,139.81914C199.86106,155.20638 260.67394,197.4423 286.3703,215.80679z"/>
<path fill="none" stroke="#000" stroke-width="1.5" stroke-linecap="round" d="M216.08561,167.51949C236.13137,186.41034 261.37565,201.82127 283.89761,218.85496"/>
<circle id="c" cx="290.4" cy="222.297" r="1.008" fill="#000"/>
<use xlink:href="#c" x="7.41957" y="6.4655991"/>
<use xlink:href="#c" x="13.93812" y="13.090317"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.0 KiB

-23
View File
@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="600">
<clipPath id="c">
<path d="M0,0V150H700V300H600zM600,0H300V350H0V300z"/>
</clipPath>
<rect width="1200" height="600" fill="#00247d"/>
<path d="M0,0 600,300M600,0 0,300" stroke="#fff" stroke-width="60"/>
<path d="M0,0 600,300M600,0 0,300" stroke="#cf142b" stroke-width="40" clip-path="url(#c)"/>
<path d="M300,0V350M0,150H700" stroke="#fff" stroke-width="100"/>
<path d="M300,0V350M0,150H700" stroke="#cf142b" stroke-width="60"/>
<path d="M0,300H600V0H800V400H0z" fill="#00247d"/>
<g>
<path fill="#cc3" d="m780.583,154.039c0,148.827,11.8732,201.675,52.6064,242.479,40.7332,40.8042,56.1659,47.2313,67.5231,53.4827,13.1015-7.21148,28.1971-15.1341,65.1152-52.0521,36.513-36.515,54.173-89.15,54.173-246.452-26.559,11.3712-39.7859,15.1175-63.0119,15.0513-17.202,1.68548-43.7399-9.33789-59.6086-16.5484-10.371,6.60246-25.4152,14.4763-52.4514,15.3604-31.2252,1.30952-41.1191-3.73522-64.3451-11.3217z"/>
<path fill="#fff" d="m787.775,163.438c0,46.0434-2.72184,108.794,7.00639,145.1,9.77001,36.4622,12.0129,41.8034,19.3596,54.5282l171.206-1.27105c10.576-18.3181,11.1098-29.6647,18.9526-58.9348,7.8148-29.1649,9.7886-94.177,10.0167-142.6-17.216,8.72445-39.7613,14.9075-61.6436,12.1948-17.5423-1.2754-33.7513-5.09258-52.6268-15.2637-16.374,9.35261-22.0822,13.6217-49.1184,14.7138-21.0507,0.98975-38.1018,2.61503-63.1522-8.46789z"/>
<path fill="#9cf" d="m814.51,362.056c12.1849,24.4477,69.6325,71.3032,86.433,81.0029,19.168-11.0667,69.8476-57.368,83.9727-81.0029h-170.406z"/>
<path fill="#f90" d="m904.221,231.606c5.41355,12.1396,22.7699,25.5448,27.5414,32.1145-6.07314,6.56934-7.28706,5.85387-6.49064,18.0587,10.5604-10.534,10.7499-11.6322,17.5423-10.0346,14.8794,14.1555,2.66292,44.5571-9.63422,51.1666-12.2936,7.05101-10.0622-0.24417-28.4886,8.59299,8.44836,6.88711,18.237-1.01015,26.2362,1.10047,4.34697,4.91697-2.06648,13.8779,1.31216,22.317,7.06953-0.6489,6.22049-14.2559,7.86595-19.1896,5.16445-18.0757,36.2143-30.6826,37.7931-47.2631,6.54677-2.93012,13.09-0.9165,21.0507,3.34487-3.96455-15.5336-17.0792-15.3664-20.5946-20.2178-8.36767-12.1907-15.7845-26.0981-33.6566-29.7059-13.5672-2.73878-12.5532,0.82385-21.2472-4.83-5.41355-4.01853-21.8612-11.6181-19.2298-5.45416z"/>
<path fill="#f90" d="m860.839,283.106c8.72935-10.2344,13.0534-31.1272,16.9171-38.2184,8.92956,2.05041,8.83312,3.40792,19.7799-2.96497-14.7027-3.98084-15.8096-3.62755-17.5012-10.0994,6.17695-19.1553,40.0786-23.0599,51.953-15.7817,12.2822,7.06894,4.4742,8.596,21.2779,20.0001,2.44044-10.3389-9.45634-14.9009-11.2359-22.6298,2.52932-5.96126,13.8358-4.74122,20.084-11.5316-3.90439-5.6561-16.127,1.41619-21.4712,2.33396-19.1762,4.09085-45.373-16.1931-61.4875-9.77821-5.77578-4.14976-6.96507-10.606-6.73193-19.3072-12.5539,10.5985-6.27225,21.5753-9.12921,26.805-7.39678,12.7485-16.8297,25.4974-11.8265,42.248,3.79803,12.7158,6.62838,10.1968,5.44639,20.1666-1.19785,6.44061-0.56211,23.8553,3.92513,18.7577z"/>
<path fill="#f90" d="m931.763,290.302c-13.7027-1.82835-34.6943,5.45107-43.0585,5.96673-2.77851-8.34642-1.51002-8.96995-12.8934-14.605,4.03197,14.0554,4.9217,14.7758-0.0129,19.5038-20.3904,4.86884-41.4321-20.7724-41.0411-34.2257-0.008-13.6779,5.40195-8.09713,6.94685-27.7067-10.5433,3.35691-8.48447,15.4235-14.502,20.8735-6.65962,1.01994-11.4131-8.83635-20.7407-10.4218-3.05765,6.11145,9.61345,12.4257,13.2018,16.3114,13.5917,13.53,8.93457,45.397,23.0288,55.2268-0.7374,6.85915-5.91783,11.1692-13.8492,15.48,16.0079,4.76053,22.612-6.04289,28.7845-6.41709,15.2702-0.5594,31.594,0.5423,44.0424-12.2046,9.45-9.67656,5.72467-10.6828,15.2857-14.8756,6.40117-2.35427,21.7049-11.8813,14.8078-12.9056z"/>

Before

Width:  |  Height:  |  Size: 4.0 KiB

-13
View File
@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg height="850" width="1300" version="1.1" xmlns="http://www.w3.org/2000/svg" id="Flag of Ã…land">
<rect fill="#0053a5" height="850" width="1300" />
<g fill="#ffce00">
<rect height="850" width="250" x="400" />
<rect height="250" width="1300" y="300" />
</g>
<g fill="#d21034">
<rect height="850" width="100" x="475" />
<rect height="100" width="1300" y="375" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 550 B

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 6.3 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 76 KiB

-5
View File
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="1200" height="600" viewBox="0 0 12 6">
<rect width="12" height="2" fill="#00732f" id="green"/>
<rect width="12" height="2" y="2" fill="#fff"/>
<rect width="12" height="2" y="4"/>
<rect width="3" height="6" fill="#f00" id="red"/></svg>

Before

Width:  |  Height:  |  Size: 326 B

-34
View File
@@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="800" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" height="500">
<rect width="800" fill="#74acdf" height="500"/>
<rect y="166.67" width="800" fill="#fff" height="166.67"/>
<g id="rays">
<path id="ray1" stroke-width="1.1116" stroke="#85340a" fill="#f6b40e" d="m396.84 251.31l28.454 61.992s0.4896 1.185 1.28 0.8586c0.7902-0.3267 0.2988-1.5116 0.2988-1.5116l-23.715-63.956m-0.68 24.12c-0.3465 9.4278 5.4526 14.613 4.6943 23.032-0.7569 8.42 3.8673 13.18 4.9396 16.454 1.0733 3.2744-1.16 5.2323-0.198 5.6982 0.96336 0.4662 3.07-2.1207 2.3833-6.7756-0.68675-4.6549-4.2204-6.0368-3.3898-16.32 0.83-10.283-4.206-12.678-2.98-22.058"/>
<use xlink:href="#ray1" transform="rotate(22.5 400,250)"/>
<use xlink:href="#ray1" transform="rotate(45 400,250)"/>
<use xlink:href="#ray1" transform="rotate(67.5 400,250)"/>
<path id="ray2" fill="#85340a" d="m404.31 274.41c0.45334 9.0538 5.5867 13.063 4.5787 21.314 2.2133-6.5249-3.1233-11.583-2.82-21.22m-7.6487-23.757l19.487 42.577-16.329-43.887"/>
<use xlink:href="#ray2" transform="rotate(22.5 400,250)"/>
<use xlink:href="#ray2" transform="rotate(45 400,250)"/>
<use xlink:href="#ray2" transform="rotate(67.5 400,250)"/>
</g>
<use xlink:href="#rays" transform="rotate(90 400,250)"/>
<use xlink:href="#rays" transform="rotate(180 400,250)"/>
<use xlink:href="#rays" transform="rotate(270 400,250)"/>
<circle r="27.778" stroke="#85340a" cy="250" cx="400" stroke-width="1.5" fill="#f6b40e"/>
<path id="loweyecontour" fill="#843511" d="m409.47 244.06c-1.8967 0.00003-3.7131 0.82183-4.7812 2.5312 2.1367 1.9227 6.8565 2.1318 10.062-0.21875-1.3883-1.4954-3.3845-2.3125-5.2812-2.3125zm-0.0312 0.4375c1.8462-0.0335 3.5717 0.81446 3.8125 1.6562-2.1367 2.3504-5.5508 2.1463-7.6875 0.4375 0.9348-1.4957 2.4391-2.0677 3.875-2.0938z"/>
<use xlink:href="#uppalpebra" transform="matrix(-1 0 0 1 800.25 0)"/>
<use xlink:href="#eyebrow_nose" transform="matrix(-1 0 0 1 800.25 0)"/>
<use xlink:href="#pupil" transform="translate(18.862)"/>
<use xlink:href="#lowpalpebra" transform="matrix(-1 0 0 1 800.25 0)"/>
<path d="m395.75 253.84c-0.91341 0.16668-1.5625 0.97727-1.5625 1.9062 0 1.0614 0.87748 1.9062 1.9375 1.9062 0.62667 0 1.2025-0.2968 1.5625-0.8125 0.73952 0.55614 1.7646 0.61511 2.3125 0.625 0.0843 0.002 0.19312 0 0.25 0 0.54791-0.01 1.573-0.0689 2.3125-0.625 0.36 0.5157 0.93583 0.8125 1.5625 0.8125 1.06 0 1.9375-0.84488 1.9375-1.9062 0-0.92898-0.64918-1.7396-1.5625-1.9062 0.513 0.1809 0.84375 0.6765 0.84375 1.2188 0 0.7074-0.57124 1.2812-1.2812 1.2812-0.6804 0-1.2413-0.54015-1.2812-1.2188-0.20862 0.41637-1.0341 1.6551-2.6562 1.7188-1.6222-0.0636-2.4476-1.3024-2.6562-1.7188-0.04 0.6786-0.60085 1.2188-1.2812 1.2188-0.71001 0-1.2812-0.57385-1.2812-1.2812 0-0.54225 0.33075-1.0378 0.84375-1.2188z" fill="#85340a"/>
<path d="m397.84 259.53c-2.138 0-2.9829 1.9368-4.9062 3.2188 1.0687-0.42633 1.9096-1.2693 3.4062-2.125 1.496-0.85442 2.7717 0.1875 3.625 0.1875h0.0312c0.8532 0 2.129-1.0416 3.625-0.1875 1.4967 0.8559 2.3688 1.6987 3.4375 2.125-1.9233-1.282-2.7996-3.2188-4.9375-3.2188-0.4266 0-1.2716 0.23055-2.125 0.65625h-0.0312c-0.85334-0.42642-1.6983-0.65625-2.125-0.65625z" fill="#85340a"/>
<path d="m397.12 262.06c-0.8439 0.0374-1.9596 0.20675-3.5625 0.6875 3.8473-0.85434 4.6962 0.4375 6.4062 0.4375h0.0312c1.71 0 2.5588-1.292 6.4062-0.4375-4.2744-1.282-5.1242-0.4375-6.4062-0.4375h-0.0312c-0.80125 0-1.4372-0.3124-2.8438-0.25z" fill="#85340a"/>
<path d="m393.75 262.72c-0.24819 0.003-0.51871 0.005-0.8125 0.0312 4.488 0.42766 2.3306 3 7.0312 3h0.0312c4.7007 0 2.5745-2.5724 7.0625-3-4.7007-0.4266-3.2146 2.3438-7.0625 2.3438h-0.0312c-3.6075 0-2.4959-2.4215-6.2188-2.375z" fill="#85340a"/>
<path d="m403.85 269.66c0-2.1234-1.7233-3.8465-3.8463-3.8465-2.1233 0-3.8463 1.723-3.8463 3.8465 0.423-1.781 2.0166-3.0393 3.8463-3.0393 1.8333 0 3.424 1.2586 3.8463 3.0393v0 0z" fill="#85340a"/>
<path id="eyebrow_nose" fill="#85340a" d="m382.73 244.02c4.9146-4.2729 11.11-4.9147 14.53-1.7086 0.837 1.1207 1.3733 2.319 1.5934 3.5696 0.4302 2.433-0.3303 5.0617-2.2367 7.7559 0.2151-0.001 0.6435 0.2124 0.8568 0.4266 1.6967-3.244 2.2967-6.5761 1.74-9.7454-0.1458-0.828-0.3735-1.643-0.6696-2.4357-4.7007-3.8452-11.11-4.2729-15.811 2.1377z"/>
<path id="uppalpebra" fill="#85340a" d="m390.42 242.74c2.7767 0 3.4186 0.6417 4.7007 1.71 1.2833 1.0683 1.9233 0.8541 2.1367 1.0683 0.2124 0.2142 0 0.8541-0.4266 0.6399s-1.2833-0.6399-2.5633-1.7086c-1.2833-1.0696-2.5633-1.0683-3.8463-1.0683-3.8463 0-5.983 3.2046-6.4094 2.9907-0.4266-0.2142 2.1367-3.6325 6.4094-3.6325z"/>
<use xlink:href="#loweyecontour" transform="translate(-19.181)"/>
<circle id="pupil" cy="246.15" cx="390.54" r="1.923" fill="#85340a"/>
<path id="lowpalpebra" fill="#85340a" d="m385.29 247.44c3.6327 2.7783 7.265 2.5644 9.4017 1.282 2.1367-1.282 2.1367-1.7086 1.71-1.7086-0.4266 0-0.8532 0.4266-2.5633 1.281-1.71 0.8559-4.273 0.8559-8.546-0.8541z"/>
</svg>

Before

Width:  |  Height:  |  Size: 4.9 KiB

-6
View File
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="600">
<rect fill="#F2A800" width="1200" height="600"/>
<rect fill="#0033A0" width="1200" height="400"/>
<rect fill="#D90012" width="1200" height="200"/>
</svg>

Before

Width:  |  Height:  |  Size: 259 B

-110
View File
@@ -1,110 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="500">
<rect height="500" width="1000" fill="#006"/>
<path d="M0,250 1000,0V500z" fill="#bd1021"/>
<path d="M107.14,250 1000,26.79V473.21" fill="#fff"/>
<g stroke="#000" stroke-width="1.72">
<path d="m832.04,306.06s-6.2429-5.108,1.135-13.337c-3.973-3.4049-0.2834-9.9312-0.2834-9.9312s-6.8111-2.5547,0.2834-13.054c-5.108-3.4049-2.8381-11.068-2.8381-11.068s-16.742-6.2429-0.85018-12.201c-13.054,5.6748-25.257-7.6626-25.257-7.6626l-19.012,0.56816c-3.2161-15.797-28.283-2.0814-9.6482-47.39-4.8242-0.85142-10.216-2.27-15.607,1.7027-5.3916,3.9728-20.715,12.486-29.796,3.9728-9.0806-8.5131,5.9593-20.715,6.2431-20.999,0.28367-0.2838,20.148-10.5,22.986-17.31-0.28381-5.108-6.5269-9.0806-0.85142-20.148,6.5267-10.5,46.538-20.432,64.701-23.837,8.7962-3.9728,12.769-11.635,12.769-11.635l1.9865,7.378s40.296-11.918,42.282-17.594c1.9865-5.6755,0.85156,5.1078,0.85156,5.1078,15.891-1.4189,36.038-15.04,38.876-8.7969,13.337-2.5539,38.877-13.905,38.877-13.905s8.7962-0.28364,2.5533,9.3646c3.973,6.2429-1.135,11.635-1.4184,11.635-0.28477,0,1.7017,6.2429-3.4062,9.6482,1.7045,5.3916-3.1215,9.6482-3.1215,9.6482s2.2713,6.5267-6.8097,9.932c0.85157,5.6755-5.108,6.8106-5.108,6.8106s0.85156,5.9593-3.1215,8.5131c0,4.5404-4.5398,6.8106-4.5398,6.8106s2.8367,1.7026-1.1363,4.5404c-3.9716,2.8377-45.119,28.093-45.119,27.81,0-0.28366,30.08,5.3917,32.066,6.5268,1.9865,1.1351,24.688,16.175,24.688,16.175l-22.987,28.377s-25.539-2.8367-26.673-1.4184c-1.135,1.4184,5.3914,1.9865,6.8097,4.2564,1.4197,2.2699,3.6896,7.6627,8.2294,7.0945,4.5412-0.56816-8.5129,8.2295-17.026,9.081,0,3.1215,10.783,3.4049,13.621,0.85155,2.8381-2.5547-6.8111,7.3779-7.9461,8.7962s12.771-1.9865,12.771-1.9865-2.2713,9.3644-14.472,12.202c4.8232,7.946,2.8367,13.054,2.5533,13.054-0.28339,0-7.946-7.946-15.324-6.5277,1.9865,7.6627,7.9461,14.756,9.6492,15.892,1.7017,1.135-13.337,0.85018-15.324-3.4062-1.9865-4.2564-3.6896,10.216,1.7018,14.757-6.2416,0.2834-11.634-3.4062-11.634-3.4062s-3.6882,8.5128-1.135,12.771c2.5547,4.2564-8.7962-8.5142-8.7962-8.5142l-21.567,9.081-4.8246-8.2294z" fill="#9c3900" stroke-linejoin="round"/>
<g fill="#ffc221">
<path d="m665.36,289.17c0.50543,0,31.331-0.50627,45.48-8.5913,7.0747,11.117,16.676,18.697,16.676,18.697l4.5481-16.17s11.117,0.50489,12.128,3.032c-1.516,3.0307-2.0213,7.0739-2.0213,7.0739s7.58,0.50627,8.0853,1.516c0.5053,1.0111-2.0213,9.601-2.0213,9.601l32.342,7.5801s2.5266-12.633,5.0532-11.117c2.5268,1.516,13.644,17.181,29.31,18.192,15.665,1.0111,16.676-13.139,16.676-13.139l3.5369,2.0223s6.569-14.149,7.5801-14.149,2.5272,2.0209,11.117,2.0209c2.5272,3.032,3.5383,10.106,3.5383,10.106s-9.6024,9.6024-6.5704,17.183c3.032,7.5801,3.5383,5.5578,3.5383,5.5578l69.736,16.676s3.5383,5.5592-2.5258,8.5913c0,0.50489-70.242-16.171-70.242-16.171s-6.5704,7.5801-11.623,6.0641c-5.053-1.516-1.516,3.032-1.516,3.032l75.8,6.0641s5.5592,7.0752,1.516,9.0962c-5.053,0.50488-81.864-5.053-81.864-5.053s-4.5481,9.601-9.601,1.516c-3.5369,5.5578-7.5801-1.516-7.5801-1.516s-6.569,5.053-7.5801-0.50626c-5.5592,4.0432-9.0961-2.5258-9.0961-2.5258l-32.341-2.0223-2.0213,3.032s5.5587,1.516-3.032,5.0543c-8.5907,3.5369,51.544,2.0209,53.06,2.5258,1.516,0.50625-4.0418,5.0543-4.0418,5.0543s30.825,2.0209,36.383-4.5481c5.5592-6.5703-2.0209,8.5899-2.0209,8.5899s24.256-1.0098,24.256-2.0209-0.50626,7.5801-17.181,6.569c10.106,6.5704,22.739,10.612,22.739,10.612s-12.633,3.032-27.287-0.50488c2.5258,6.569,13.644,12.633,13.644,12.633s-8.0864,7.0752-26.279-10.107c5.0543,9.0962,1.0111,12.634,0.50625,11.623-0.50625-1.0111-9.0961-13.644-29.309-18.192,12.633,8.085,7.0739,11.623,7.0739,11.623s-6.569-11.623-17.181,0c-4.0432-10.612-19.708-16.676-38.911-17.687-6.064-7.0739-9.6014-5.0529-23.751-9.0961-8.0853-9.0948-19.708-19.202-19.708-19.202s0.5053-13.644,14.149-12.128c1.516,4.5481,1.516,3.032,1.516,3.032s15.16-5.5592,19.708,2.0209c6.5692-11.623,15.665-1.7375,17.181,2.3043,4.3537,0.63832,26.278,1.2326,26.278,1.2326s-2.5272-4.5481-1.0112-4.0418c1.516,0.50488,13.644-4.5481,13.139-6.0641-0.50625-1.516-1.0111-6.569,1.0098-6.0641,2.0223,0.50489-17.181-2.5272-27.793,5.5592-3.5373-3.5383-1.0106-13.139-1.0106-13.139l-31.331-6.569-1.516,8.085s-9.096,1.516-8.5907-0.50487c0.50529-2.0223-2.0213,7.0739-2.0213,7.0739s-12.128-3.0321-12.128-3.5369c0-0.50489,3.5374-18.192,3.5374-17.687,0,0.50626-10.107,1.0112-24.256,11.623-4.0426-12.633-35.879-29.309-35.879-29.814z"/>
<path d="m704.78,247.73s-21.224,18.191,0,28.803c1.0106-7.0752,2.5268-8.085,2.5268-8.085s17.687,6.569,28.299-9.0961c-4.5481-6.569-12.633-4.0418-12.633-4.0418s-16.676-0.001-18.192-7.5801z"/>
</g>
<path d="m722.47,255.82-14.655,12.633" fill="none"/>
<g fill="#fff">
<path d="m705.48,247.88,0,0s2.8377-2.8381,3.6891-6.2429c0.85129-3.4049-1.1351-7.0945,2.2702-10.216,3.4051-3.1215,48.241-22.134,51.93-25.823,3.6891-3.6888,10.499-11.634,11.351-13.337,0.85129-1.7027,3.4053,8.5131-4.2566,13.054,8.2293-2.2707,13.621-4.8243,17.026-3.6892-3.4058,4.8242-12.486,12.77-16.743,12.77,9.932-3.6896,19.012-6.8111,21.567-4.8246,2.5533,1.9865-12.202,11.919-18.162,12.486,9.932-2.5533,23.27-6.5263,24.971-2.2699-5.3914,1.7031-3.6896,3.1201-14.756,9.3644-1.4188,1.1363-8.5131,1.4184-8.5131,1.4184,8.5131-0.85156,20.147-4.2564,21.282,1.9865-6.8097,2.5533-9.3639,5.9595-15.039,7.3779-5.6755,1.4197-18.729,3.973-26.675,7.0945-7.9455,3.1215-19.58,12.202-19.58,12.202s-25.256,0.85155-25.256,0.56678c0-0.28339-4.824-11.634-5.1078-11.918z" stroke-linejoin="round"/>
<path d="m921.99,230.57,49.092,9.3644s5.3928-6.2429,2.5547-9.6478c7.3779-1.7017,5.3914-11.351,5.3914-11.351s8.5128-3.6883,1.4183-12.202c4.826-4.8239-1.135-8.5128-1.135-8.5128s1.9865-8.5131-4.2564-9.3644c1.7031-6.8104-10.783-9.0807-10.783-9.0807s-25.823,7.0944-43.985,7.6618c5.9595,5.9593-2.2699,9.6482-2.2699,9.6482s4.8246,3.4053,3.4049,6.2429c-1.4183,2.8382,0.85157,5.9597-5.3914,7.9462,8.2294,3.6896-0.85156,9.9312-0.85156,9.9312s9.081,6.2429,6.8111,9.3644z"/>
</g>
<g fill="none">
<path d="m742.17,293.72-6.5694,29.309"/>
<path d="m748.24,304.83-2.0213,9.601"/>
<path d="m780.58,312.41-3.032,9.0962"/>
<path d="m836.67,374.06c-0.50489,0-16.17,2.0209-18.192,1.516-2.0209-0.50489,24.761,8.085,24.761,11.622"/>
<path d="m808.37,377.6s-15.666-10.106-18.192-9.0961c-2.5269,1.0111,15.665-0.50489,17.181-2.0209"/>
<path d="m776.03,365.98s-16.171,0.50488-17.687-1.0111,15.665,11.117,18.697,10.107"/>
<path d="m744.7,358.9c-0.5053,0-11.117-4.0418-15.665-5.0543,4.0426,4.0432,7.0747,9.6024,17.181,11.623"/>
<path d="m748.74,352.34c-0.50529-1.0111-20.213-7.0752-20.213-10.107,4.5481,1.516,11.117,3.5369,17.181,2.0209"/>
<path d="m853.35,329.09-2.0209,9.0948"/>
<path d="m767.6,343.56s3.3779,3.724,0.34585,8.2721"/>
<path d="m838.69,347.28-5.5578,0.50625"/>
<path d="m793.21,344.25,10.106,1.516"/>
<path d="m820.4,318.26s0.2834,10.216-8.2294,9.9326c-8.5128-0.28477-5.6762,0.2834-5.6762,0.2834"/>
<path d="m826.93,316.55s3.4049,1.135,2.5547,3.6896c-0.85155,2.5533,0.85018,9.9312-9.081,17.026-10.501,2.2699-9.3644-8.7962-9.3644-8.7962"/>
<path d="m830.62,319.68s6.2429-3.6883,7.0945,2.2713c0.85018,5.9582-5.108,17.026-9.3644,18.729-4.2578,1.7018-9.081-0.28476-8.5142-3.1215"/>
<path d="m838.28,322.23s5.6762-4.5412,7.3779,1.4184c1.7031,5.9596-4.5398,19.297-7.0945,19.58"/>
<path d="m846.23,323.65s2.8381-1.4184,4.8232,0.28339"/>
<path d="m837.15,344.08c-1.135,0.28339-5.9595,0.56678-7.6613-3.1215"/>
<path d="m811.61,334.15c-0.28339,0-5.9582,0.28476-5.9582,0.28476"/>
<path d="m833.46,356.57-0.56679-9.3644-2.2699-3.1215-3.973,3.973s-0.56816,9.3644-2.2699,10.216"/>
<path d="m826.65,347.77c-0.28339-0.56678-3.1215-5.9582-3.1215-5.9582l-4.8246,5.9582s-0.5668,8.5142-2.2699,9.3658"/>
<path d="m818.7,347.49c0-0.28339-1.9865-5.6748-1.9865-5.6748s-5.6748,3.1215-6.2429,5.3914c-0.56679,2.2699-0.85156,8.5128-2.2699,9.081"/>
<path d="m810.47,346.07s0.56816-5.108-1.135-5.108c-1.7018,0-9.3644,7.0945-9.6478,13.337"/>
<path d="m717.39,245.9s0.28382-5.6748,2.8377-7.6613c2.554-1.9865,15.324-6.8111,18.161-11.068,2.8377-4.2564-4.2566,7.3779-3.1215,10.499"/>
<path d="m722.5,237.38s6.2431,2.2713,4.8242,7.0945"/>
<path d="m57.344,126.01a3.9192,3.9192,0,1,1,-7.8384,0,3.9192,3.9192,0,1,1,7.8384,0z" transform="matrix(1.1946929,0,0,1.1946929,661.37184,90.106184)" stroke-width="1pt"/>
<path d="m917.17,220.07,0,0s43.417,5.108,45.404,5.108c1.9865,0,9.6478,2.5547,11.068,5.108"/>
<path d="m919.44,217.52,60.443,1.4184"/>
<path d="m919.72,216.1s57.321-3.4049,61.294-9.3644"/>
<path d="m921.43,203.61s57.606-6.2429,58.174-5.3916"/>
<path d="m919.44,196.52s55.903-8.7969,56.47-7.378"/>
<path d="m759.96,160.48s17.594,19.296,15.891,32.35"/>
<path d="m774.72,182.61s5.6753,8.2293,7.9455,9.0806c2.2702,0.85128,22.134,1.9864,23.269,10.5,1.135,5.3916-4.2564,3.6885-3.4049,7.6616,1.4184,5.108,14.756,11.634,29.228,3.973"/>
<path d="m818.42,217.8s11.918,17.594,29.512-1.4183"/>
<path d="m838.85,224.05s14.472,7.6613,26.39-12.202"/>
<path d="m849.92,225.75s7.0945,5.9596,21.852-1.9851"/>
<path d="m892.2,215.82s21.85,4.5398,23.27,5.9596"/>
<path d="m900.43,210.99c0.28339,0,15.324,0.56817,15.324,0.56817"/>
<path d="m891.06,202.48s26.107-1.7026,29.513,3.6895"/>
<path d="m879.71,194.25s36.607,1.4188,38.309,3.4053"/>
<path d="m887.94,231.71s6.2429-1.7017,7.0945-0.85019"/>

Before

Width:  |  Height:  |  Size: 13 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 6.7 KiB

-18
View File
@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="400">
<defs>
<path id="s" transform="scale(21)" fill="#fff" d="M0,-1 L0.58779,0.80902 L-0.95106,-0.30902 L0.95106,-0.30902 L-0.58779,0.80902z"/>
</defs>
<rect fill="#002395" height="400" width="600" />
<rect fill="#fff" height="164" width="244" />
<rect fill="#002395" height="160" width="80" />
<rect fill="#ED2939" height="160" width="80" x="160"/>
<path fill="#fff" d="M355,183 l12.875,20.5 h36.625 v71.5 l-27.5,-43 -37,59 h18 l19,-34 39,70 39,-70 19,34 h18 l-37,-59 -27.5,43 v-39.5 h16.5 l12.25,-19.5 h-28.75 v-12.5 h36.625 l12.875,-20.5 h-122z
M398,270.5h-40v14h40z
M474,270.5h-40v14h40z"/>
<use xlink:href="#s" x="416" y="362"/>
<use xlink:href="#s" x="371" y="328"/>
<use xlink:href="#s" x="461" y="328"/>
<use xlink:href="#s" x="333" y="227"/>
<use xlink:href="#s" x="499" y="227"/>
</svg>

Before

Width:  |  Height:  |  Size: 986 B

-17
View File
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="690" height="460" viewBox="0 0 138 92">
<rect width="138" height="92" fill="#fff"/>
<rect width="138" height="36" fill="#000"/>
<g transform="translate(69,36)">
<g id="c3">
<!-- y3 = -y2 = 30*sin(11.25deg)/sqrt(5-4*cos(11.25deg)-sin^2(11.25deg)) -->
<path id="c" d="M-30,0 0,-5.7423716V5.7423716z" fill="#fcd116"/>
<use xlink:href="#c" transform="rotate(22.5)"/>
<use xlink:href="#c" transform="rotate(45)"/>
</g>
<use xlink:href="#c3" transform="rotate(67.5)"/>
<use xlink:href="#c3" transform="rotate(135)"/>
</g>
<rect y="36" width="138" height="20" fill="#0072c6"/>
<path d="M0,0V92H138V0L69,92z" fill="#ce1126"/>
</svg>

Before

Width:  |  Height:  |  Size: 769 B

-1
View File
@@ -1 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1280" height="640" viewBox="0 0 30240 15120"><defs id="defs6"><polygon points="0,-9 1.735535,-3.6038755 7.0364833,-5.6114082 3.8997116,-0.89008374 8.7743512,2.0026884 3.1273259,2.4939592 3.9049537,8.1087198 0,4 -3.9049537,8.1087198 -3.1273259,2.4939592 -8.7743512,2.0026884 -3.8997116,-0.89008374 -7.0364833,-5.6114082 -1.735535,-3.6038755 0,-9 " id="Star7"/><polygon points="0,-9 2.351141,-3.236068 8.5595086,-2.7811529 3.8042261,1.236068 5.2900673,7.2811529 0,4 -5.2900673,7.2811529 -3.8042261,1.236068 -8.5595086,-2.7811529 -2.351141,-3.236068 0,-9 " id="Star5"/></defs><path d="M 0,0 L 30240,0 L 30240,15120 L 0,15120 L 0,0 z" style="fill:#00008b"/><use transform="matrix(252,0,0,252,7560,11340)" id="Commonwealth_Star" style="fill:#fff" xlink:href="#Star7"/><use transform="matrix(120,0,0,120,22680,12600)" id="Star_Alpha_Crucis" style="fill:#fff" xlink:href="#Star7"/><use transform="matrix(120,0,0,120,18900,6615)" id="Star_Beta_Crucis" style="fill:#fff" xlink:href="#Star7"/><use transform="matrix(120,0,0,120,22680,2520)" id="Star_Gamma_Crucis" style="fill:#fff" xlink:href="#Star7"/><use transform="matrix(120,0,0,120,26040,5607)" id="Star_Delta_Crucis" style="fill:#fff" xlink:href="#Star7"/><use transform="matrix(70,0,0,70,24192,8190)" id="Star_Epsilon_Crucis" style="fill:#fff" xlink:href="#Star5"/><path d="M 6300,0 L 8820,0 L 8820,2520 L 15120,2520 L 15120,5040 L 8820,5040 L 8820,7560 L 6300,7560 L 6300,5040 L 0,5040 L 0,2520 L 6300,2520 L 6300,0 z" id="White_Cross" style="fill:#fff"/><path d="M 0,0 L 1690.4674,0 L 15120,6714.7663 L 15120,7560 L 13429.533,7560 L 0,845.2337 L 0,0 z" id="White_Diagonal" style="fill:#fff"/><use transform="matrix(-1,0,0,1,15120,0)" id="White_Diagonal_Flipped" style="fill:#fff" xlink:href="#White_Diagonal"/><path d="M 6804,0 L 8316,0 L 8316,3024 L 15120,3024 L 15120,4536 L 8316,4536 L 8316,7560 L 6804,7560 L 6804,4536 L 0,4536 L 0,3024 L 6804,3024 L 6804,0 z" id="Red_Cross" style="fill:red"/><path d="M 0,0 L 5040,2520 L 3913.0217,2520 L 0,563.48913 L 0,0 z M 15120,0 L 13993.022,0 L 8953.0217,2520 L 10080,2520 L 15120,0 z" id="Red_Diagonals" style="fill:red"/><use transform="matrix(-1,0,0,-1,15120,7560)" id="Red_Diagonals_Rotated" style="fill:red" xlink:href="#Red_Diagonals"/></svg>

Before

Width:  |  Height:  |  Size: 2.3 KiB

-5
View File
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="900" height="600">
<rect fill="#ed2939" width="900" height="600"/>
<rect fill="#fff" y="200" width="900" height="200"/>
</svg>

Before

Width:  |  Height:  |  Size: 216 B

-12
View File
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="520" height="340" viewBox="0 0 260 170">
<rect fill="#0064AE" width="260" height="170"/>
<g fill="#FFD300">
<rect x="80" width="50" height="170"/>
<rect y="60" width="260" height="50"/>
</g>
<g fill="#DB0F16">
<rect x="95" width="20" height="170"/>
<rect y="75" width="260" height="20"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 386 B

-8
View File
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="1200" height="600">
<rect width="1200" height="600" style="fill:#0098c3"/>
<rect width="1200" height="200" y="200" style="fill:#e00034"/>
<rect width="1200" height="200" y="400" style="fill:#00ae65"/>
<circle fill="#fff" cx="581" cy="300" r="90"/>
<circle fill="#e00034" cx="600" cy="300" r="75"/>
<path d="M 716.38014,335.33055 690.58329,323.09028 681.03508,350 671.44912,323.1037 645.66947,335.38014 657.90973,309.58329 631,300.03508 l 26.89631,-9.58596 -12.27645,-25.77965 25.79686,12.24026 9.54821,-26.90973 9.58596,26.8963 25.77965,-12.27644 -12.24026,25.79686 26.90973,9.5482 -26.8963,9.58596 z" style="fill:#fff"/>
</svg>

Before

Width:  |  Height:  |  Size: 722 B

-27
View File
@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="500" height="300">
<defs>
<g id="b" fill="#1eb53a">
<g id="s">
<g id="t">
<g id="c">
<path id="h" d="M0,-20V0H20" transform="rotate(30,0,-20)"/>
<use xlink:href="#h" transform="scale(-1,1)"/>
</g>
<use xlink:href="#c" transform="rotate(120)"/>
<use xlink:href="#c" transform="rotate(240)"/>
</g>
<use xlink:href="#t" transform="rotate(180)"/>
</g>
<use xlink:href="#s" fill="#ce1126" transform="scale(0.82)"/>
</g>
<use id="star" xlink:href="#b" x="250" y="106"/>
</defs>
<path d="M0,0H500L0,300H500z" fill="#ce1126"/>
<path d="M0,0V300L500,0V300z" fill="#1eb53a"/>
<path d="M0,0 500,300M500,0 0,300" stroke="#fff" stroke-width="40"/>
<circle cx="250" cy="150" r="85" fill="#fff"/>
<use xlink:href="#star"/>
<use xlink:href="#star" transform="rotate(120,250,150)"/>
<use xlink:href="#star" transform="rotate(240,250,150)"/>
</svg>

Before

Width:  |  Height:  |  Size: 985 B

-6
View File
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="450" height="390">
<rect width="450" height="390" fill="#ED2939"/>
<rect width="300" height="390" fill="#FAE042"/>
<rect width="150" height="390"/>
</svg>

Before

Width:  |  Height:  |  Size: 241 B

-6
View File
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" width="1500" height="1000" viewBox="0 0 15 10">
<rect width="15" height="10" fill="#fcd116" id="Yellow"/>
<rect width="15" height="5" y="5" fill="#e8112d" id="Red"/>
<rect width="6" height="10" fill="#008751" id="Green"/>
</svg>

Before

Width:  |  Height:  |  Size: 328 B

-14
View File
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="600" height="400">
<rect width="600" height="400" fill="#fff" />
<path d="M 600,400 0,400 600,0 z" fill="#012a87" />
<path d="M 0,0 0,166.666667 250,0 z" fill="#f9d90f" />
<circle cx="165" cy="173" r="80" fill="none" stroke="#000" stroke-width="11" />
<g id="g">
<path d="m 165,69.834474 15,25.98076211 -30,0 z" fill="#000" id="a"/>
<use xlink:href="#a" transform="rotate(180,165,173)" />
</g>
<use xlink:href="#g" transform="rotate(90,165,173)" />
<path d="M 165,122 209.16729559,198.5 120.83270441,198.5 z" fill="#dc171d" id="b" />
<use xlink:href="#b" transform="rotate(60,165,173)" />
</svg>

Before

Width:  |  Height:  |  Size: 737 B

Some files were not shown because too many files have changed in this diff Show More