@@ -264,15 +264,15 @@ static class Asn extends AbstractBase<AsnResult> {
264264
265265 @ Override
266266 protected Map <String , Object > transform (final Result <AsnResult > result ) {
267- AsnResult response = result .result ;
267+ AsnResult response = result .result () ;
268268 Long asn = response .asn ;
269269 String organizationName = response .name ;
270- String network = result .network ;
270+ String network = result .network () ;
271271
272272 Map <String , Object > data = new HashMap <>();
273273 for (Database .Property property : this .properties ) {
274274 switch (property ) {
275- case IP -> data .put ("ip" , result .ip );
275+ case IP -> data .put ("ip" , result .ip () );
276276 case ASN -> {
277277 if (asn != null ) {
278278 data .put ("asn" , asn );
@@ -316,12 +316,12 @@ static class Country extends AbstractBase<CountryResult> {
316316
317317 @ Override
318318 protected Map <String , Object > transform (final Result <CountryResult > result ) {
319- CountryResult response = result .result ;
319+ CountryResult response = result .result () ;
320320
321321 Map <String , Object > data = new HashMap <>();
322322 for (Database .Property property : this .properties ) {
323323 switch (property ) {
324- case IP -> data .put ("ip" , result .ip );
324+ case IP -> data .put ("ip" , result .ip () );
325325 case COUNTRY_ISO_CODE -> {
326326 String countryIsoCode = response .country ;
327327 if (countryIsoCode != null ) {
@@ -359,12 +359,12 @@ static class Geolocation extends AbstractBase<GeolocationResult> {
359359
360360 @ Override
361361 protected Map <String , Object > transform (final Result <GeolocationResult > result ) {
362- GeolocationResult response = result .result ;
362+ GeolocationResult response = result .result () ;
363363
364364 Map <String , Object > data = new HashMap <>();
365365 for (Database .Property property : this .properties ) {
366366 switch (property ) {
367- case IP -> data .put ("ip" , result .ip );
367+ case IP -> data .put ("ip" , result .ip () );
368368 case COUNTRY_ISO_CODE -> {
369369 String countryIsoCode = response .country ;
370370 if (countryIsoCode != null ) {
@@ -418,12 +418,12 @@ static class PrivacyDetection extends AbstractBase<PrivacyDetectionResult> {
418418
419419 @ Override
420420 protected Map <String , Object > transform (final Result <PrivacyDetectionResult > result ) {
421- PrivacyDetectionResult response = result .result ;
421+ PrivacyDetectionResult response = result .result () ;
422422
423423 Map <String , Object > data = new HashMap <>();
424424 for (Database .Property property : this .properties ) {
425425 switch (property ) {
426- case IP -> data .put ("ip" , result .ip );
426+ case IP -> data .put ("ip" , result .ip () );
427427 case HOSTING -> {
428428 if (response .hosting != null ) {
429429 data .put ("hosting" , response .hosting );
@@ -460,16 +460,9 @@ protected Map<String, Object> transform(final Result<PrivacyDetectionResult> res
460460 }
461461 }
462462
463- /**
464- * Just a little record holder -- there's the data that we receive via the binding to our record objects from the Reader via the
465- * getRecord call, but then we also need to capture the passed-in ip address that came from the caller as well as the network for
466- * the returned DatabaseRecord from the Reader.
467- */
468- public record Result <T >(T result , String ip , String network ) {}
469-
470463 /**
471464 * The {@link IpinfoIpDataLookups.AbstractBase} is an abstract base implementation of {@link IpDataLookup} that
472- * provides common functionality for getting a {@link IpinfoIpDataLookups .Result} that wraps a record from a {@link IpDatabase}.
465+ * provides common functionality for getting a {@link IpDataLookup .Result} that wraps a record from a {@link IpDatabase}.
473466 *
474467 * @param <RESPONSE> the record type that will be wrapped and returned
475468 */
@@ -491,19 +484,20 @@ public Set<Database.Property> getProperties() {
491484 @ Override
492485 public final Map <String , Object > getData (final IpDatabase ipDatabase , final String ipAddress ) {
493486 final Result <RESPONSE > response = ipDatabase .getResponse (ipAddress , this ::lookup );
494- return (response == null || response .result == null ) ? Map .of () : transform (response );
487+ return (response == null || response .result () == null ) ? Map .of () : transform (response );
495488 }
496489
497490 @ Nullable
498491 private Result <RESPONSE > lookup (final Reader reader , final String ipAddress ) throws IOException {
499492 final InetAddress ip = InetAddresses .forString (ipAddress );
500- final DatabaseRecord <RESPONSE > record = reader .getRecord (ip , clazz );
501- final RESPONSE data = record .getData ();
502- return (data == null ) ? null : new Result <>(data , NetworkAddress .format (ip ), record .getNetwork ().toString ());
493+ final DatabaseRecord <RESPONSE > entry = reader .getRecord (ip , clazz );
494+ final RESPONSE data = entry .getData ();
495+ return (data == null ) ? null : new Result <>(data , NetworkAddress .format (ip ), entry .getNetwork ().toString ());
503496 }
504497
505498 /**
506- * Extract the configured properties from the retrieved response
499+ * Extract the configured properties from the retrieved response.
500+ *
507501 * @param response the non-null response that was retrieved
508502 * @return a mapping of properties for the ip from the response
509503 */
0 commit comments