Skip to content

Conversation

@oschwald
Copy link
Member

  • Update to geoip2 5.0.0-SNAPSHOT
  • Convert response classes to Java records
  • Use record-style method naming for request and exception classes
  • Use var for local variable declarations
  • Use record-style accessors in tests
  • Replace Collections.singletonList() with List.of()
  • Make AbstractLocation a sealed class

oschwald and others added 4 commits October 23, 2025 12:30
This introduces breaking changes due to changes in the geoip2 library:

- IpAddress no longer extends InsightsResponse (now final in geoip2 5.0.0).
  Changed to use composition with delegation methods. All public methods
  remain the same, but code relying on IpAddress being an InsightsResponse
  will need to be updated.

- GeoIp2Location no longer extends Location (now final in geoip2 5.0.0).
  Changed to store location data directly as fields. All public methods
  remain the same, but code relying on GeoIp2Location being a Location
  will need to be updated.

- Removed getMaxMind() method from IpAddress as this data is not populated
  in minFraud responses.

- Updated test data to remove deprecated is_satellite_provider field that
  was removed in geoip2 5.0.0.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This change makes these classes more concise and provides better
immutability guarantees.

All `get*()` accessor methods in response classes are now deprecated
and will be removed in 5.0.0. Use the automatically generated record
accessor methods instead (e.g., use `riskScore()` instead of
`getRiskScore()`).

The response class hierarchy has been flattened. `InsightsResponse` no
longer extends `ScoreResponse`, and `FactorsResponse` no longer extends
`InsightsResponse`. Instead, `InsightsResponse` and `FactorsResponse`
now include all fields from their former parent classes directly.

All response classes now implement `JsonSerializable` instead of
extending `AbstractModel`. The `toJson()` method remains available for
serialization.

Removed the `AbstractAddress` interface as it provided no value with
records.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Updated all request and exception classes to use record-style method
naming by removing the "get" prefix from accessor methods. This provides
consistency with the response classes that were recently converted to
Java records.

Request classes updated:
- Account, Email, Device, CreditCard, Transaction, TransactionReport
- Billing, Shipping, AbstractLocation, ShoppingCartItem
- Payment, Order, Event, CustomInputs

Exception classes updated:
- HttpException (httpStatus, uri)
- InvalidRequestException (code, httpStatus, uri)

Unlike response classes, no deprecated helper methods were added as
these methods are primarily used for serialization.

All 210 tests pass successfully.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This updates local variables throughout the codebase to use var instead
of explicit type names, making the code more concise while maintaining
readability.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@oschwald oschwald requested a review from Copilot October 24, 2025 16:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes the minFraud API in preparation for a major release by converting response classes to Java records, adopting record-style method naming across request and exception classes, and updating to geoip2 5.0.0-SNAPSHOT.

Key changes:

  • Converted all response classes from traditional classes to Java records with deprecated getter methods for backward compatibility
  • Renamed accessor methods in request and exception classes from get*() to record-style naming (e.g., getUserId()userId())
  • Updated geoip2 dependency to 5.0.0-SNAPSHOT and refactored affected classes to use composition instead of inheritance

Reviewed Changes

Copilot reviewed 78 out of 78 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pom.xml Added snapshot repository configuration and updated geoip2 dependency to 5.0.0-SNAPSHOT
CHANGELOG.md Documented all breaking changes and new features for the major release
src/main/java/com/maxmind/minfraud/JsonSerializable.java Added new interface for JSON serialization to replace AbstractModel
src/main/java/com/maxmind/minfraud/response/*.java Converted response classes to records with deprecated getters
src/main/java/com/maxmind/minfraud/request/*.java Updated to use record-style accessor naming
src/main/java/com/maxmind/minfraud/exception/*.java Updated to use record-style accessor naming
src/test/java/**/*.java Updated tests to use new record-style accessors and modernized with var declarations
src/test/resources/test-data/*.json Removed deprecated is_satellite_provider field and added represented_country test data

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

* @return The risk associated with the IP address.
*/
Double getRisk();
Double risk();
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new risk() method lacks documentation. Add a JavaDoc comment explaining what this method returns, consistent with the existing deprecated method's documentation.

Copilot uses AI. Check for mistakes.
oschwald and others added 4 commits October 24, 2025 10:07
Update all test files to use record-style accessor methods (without
the 'get' prefix) instead of the deprecated getter methods. This
eliminates deprecation warnings and follows the new record-based API
patterns introduced in version 4.0.0.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Use the more modern and concise List.of() factory method instead of
Collections.singletonList() for creating immutable single-element lists.
This is the preferred approach in Java 9+.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Seal AbstractLocation to explicitly declare its only permitted subclasses
(Billing and Shipping). This makes the type hierarchy more explicit and
enables better pattern matching and exhaustiveness checking in Java 17+.

Note: MinFraudException was already using sealed classes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants