@@ -229,7 +229,7 @@ protected Map<String, Object> transform(final CacheableAsnResponse response) {
229229 }
230230 }
231231
232- public record CacheableCityResponse (
232+ record CacheableCityResponse (
233233 Boolean isInEuropeanUnion ,
234234 String countryIsoCode ,
235235 String countryName ,
@@ -246,29 +246,7 @@ public record CacheableCityResponse(
246246 Boolean registeredCountryIsInEuropeanUnion ,
247247 String registeredCountryIsoCode ,
248248 String registeredCountryName
249- ) implements GeoIpCache .CacheableValue {
250-
251- public static CacheableCityResponse from (CityResponse response ) {
252- return new CacheableCityResponse (
253- MaxmindIpDataLookups .isInEuropeanUnion (response .getCountry ()),
254- response .getCountry ().getIsoCode (),
255- response .getCountry ().getName (),
256- response .getContinent ().getCode (),
257- response .getContinent ().getName (),
258- MaxmindIpDataLookups .regionIsoCode (response .getCountry (), response .getMostSpecificSubdivision ()),
259- response .getMostSpecificSubdivision ().getName (),
260- response .getCity ().getName (),
261- response .getLocation ().getTimeZone (),
262- response .getLocation ().getLatitude (),
263- response .getLocation ().getLongitude (),
264- response .getLocation ().getAccuracyRadius (),
265- response .getPostal ().getCode (),
266- MaxmindIpDataLookups .isInEuropeanUnion (response .getRegisteredCountry ()),
267- response .getRegisteredCountry ().getIsoCode (),
268- response .getRegisteredCountry ().getName ()
269- );
270- }
271- }
249+ ) implements GeoIpCache .CacheableValue {}
272250
273251 static class City extends AbstractBase <CityResponse , Result <CacheableCityResponse >> {
274252 City (final Set <Database .Property > properties ) {
@@ -277,10 +255,36 @@ static class City extends AbstractBase<CityResponse, Result<CacheableCityRespons
277255
278256 @ Override
279257 protected Result <CacheableCityResponse > cacheableRecord (CityResponse response ) {
258+ final com .maxmind .geoip2 .record .Country country = response .getCountry ();
259+ final Continent continent = response .getContinent ();
260+ final Subdivision subdivision = response .getMostSpecificSubdivision ();
261+ final com .maxmind .geoip2 .record .City city = response .getCity ();
262+ final Location location = response .getLocation ();
263+ final Postal postal = response .getPostal ();
264+ final com .maxmind .geoip2 .record .Country registeredCountry = response .getRegisteredCountry ();
265+ final Traits traits = response .getTraits ();
266+
280267 return new Result <>(
281- CacheableCityResponse .from (response ),
282- response .getTraits ().getIpAddress (),
283- response .getTraits ().getNetwork ().toString ()
268+ new CacheableCityResponse (
269+ isInEuropeanUnion (country ),
270+ country .getIsoCode (),
271+ country .getName (),
272+ continent .getCode (),
273+ continent .getName (),
274+ regionIsoCode (country , subdivision ),
275+ subdivision .getName (),
276+ city .getName (),
277+ location .getTimeZone (),
278+ location .getLatitude (),
279+ location .getLongitude (),
280+ location .getAccuracyRadius (),
281+ postal .getCode (),
282+ isInEuropeanUnion (registeredCountry ),
283+ registeredCountry .getIsoCode (),
284+ registeredCountry .getName ()
285+ ),
286+ traits .getIpAddress (),
287+ traits .getNetwork ().toString ()
284288 );
285289 }
286290
@@ -418,7 +422,7 @@ protected Map<String, Object> transform(final CacheableConnectionTypeResponse re
418422 }
419423 }
420424
421- public record CacheableCountryResponse (
425+ record CacheableCountryResponse (
422426 Boolean isInEuropeanUnion ,
423427 String countryIsoCode ,
424428 String countryName ,
@@ -427,21 +431,7 @@ public record CacheableCountryResponse(
427431 Boolean registeredCountryIsInEuropeanUnion ,
428432 String registeredCountryIsoCode ,
429433 String registeredCountryName
430- ) implements GeoIpCache .CacheableValue {
431-
432- public static CacheableCountryResponse from (CountryResponse response ) {
433- return new CacheableCountryResponse (
434- MaxmindIpDataLookups .isInEuropeanUnion (response .getCountry ()),
435- response .getCountry ().getIsoCode (),
436- response .getCountry ().getName (),
437- response .getContinent ().getCode (),
438- response .getContinent ().getName (),
439- MaxmindIpDataLookups .isInEuropeanUnion (response .getRegisteredCountry ()),
440- response .getRegisteredCountry ().getIsoCode (),
441- response .getRegisteredCountry ().getName ()
442- );
443- }
444- }
434+ ) implements GeoIpCache .CacheableValue {}
445435
446436 static class Country extends AbstractBase <CountryResponse , Result <CacheableCountryResponse >> {
447437 Country (final Set <Database .Property > properties ) {
@@ -450,10 +440,23 @@ static class Country extends AbstractBase<CountryResponse, Result<CacheableCount
450440
451441 @ Override
452442 protected Result <CacheableCountryResponse > cacheableRecord (CountryResponse response ) {
443+ final com .maxmind .geoip2 .record .Country country = response .getCountry ();
444+ final Continent continent = response .getContinent ();
445+ final com .maxmind .geoip2 .record .Country registeredCountry = response .getRegisteredCountry ();
446+ final Traits traits = response .getTraits ();
453447 return new Result <>(
454- CacheableCountryResponse .from (response ),
455- response .getTraits ().getIpAddress (),
456- response .getTraits ().getNetwork ().toString ()
448+ new CacheableCountryResponse (
449+ isInEuropeanUnion (country ),
450+ country .getIsoCode (),
451+ country .getName (),
452+ continent .getCode (),
453+ continent .getName (),
454+ isInEuropeanUnion (registeredCountry ),
455+ registeredCountry .getIsoCode (),
456+ registeredCountry .getName ()
457+ ),
458+ traits .getIpAddress (),
459+ traits .getNetwork ().toString ()
457460 );
458461 }
459462
0 commit comments