Skip to content

Conversation

oschwald
Copy link
Member

  • Move model and record classes to records
  • Deprecate get methods in non-record classes*

@oschwald oschwald force-pushed the greg/eng-3230 branch 2 times, most recently from 09437e4 to 98265c6 Compare October 14, 2025 15:40
oschwald and others added 9 commits October 23, 2025 12:04
This will eventually reduce boilerplate and provide a more consistent
experience for users. I am leaving the old getter methods as deprecated
for one major version to give users the ability to upgrade before having
to migrate to the updated accessors. There are other breaking changes,
but these will likely not affect most users.
Public getter methods in non-record classes (DatabaseReader, exception
classes) have been renamed to follow the same naming convention as
records (e.g., metadata() instead of getMetadata()). The old getter
methods are still available but have been deprecated and will be removed
in version 6.0.0.

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Bump maxmind-db dependency from 3.2.0 to 4.0.0-SNAPSHOT
- Update method calls to use record-style accessors instead of deprecated
  JavaBean-style getters in DatabaseReader.java and test files
- Changes include: getDatabaseType() → databaseType(), getData() → data(),
  getNetwork() → network(), getNetworkAddress() → networkAddress(),
  getPrefixLength() → prefixLength()

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

Co-Authored-By: Claude <noreply@anthropic.com>
With maxmind-db 4.0.0, records automatically use their canonical
constructor for deserialization when no constructor is explicitly
annotated with @MaxMindDbConstructor. This change removes the
annotation from most records in the codebase.

Changes:
- Removed empty canonical constructors from records with no logic
- Removed @MaxMindDbConstructor from canonical constructors with
  immutability/validation logic, relying on automatic detection
- Added useDefault=true to boolean parameters to leverage automatic
  null-to-false conversion instead of manual Boolean→boolean handling
- Kept @MaxMindDbConstructor only for records requiring custom type
  conversions (String→LocalDate in AnonymousPlusResponse, String→enum
  in ConnectionTypeResponse and Traits)
- Removed unused MaxMindDbConstructor imports

All tests pass.

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove copy constructors from model classes that only populated IP address and network
  (AnonymousIpResponse, AnonymousPlusResponse, ConnectionTypeResponse, AsnResponse,
  DomainResponse, IspResponse, IpRiskResponse)
- Update DatabaseReader getter methods to return responses directly
- Update annotations to use @MaxMindDbIpAddress and @MaxMindDbNetwork for context injection
- Remove @MaxMindDbConstructor from Traits that was only needed for ConnectionType conversion
- Add @MaxMindDbCreator to ConnectionType.fromString() for enum deserialization

These constructors are no longer needed since IP address and network are now automatically
injected via @MaxMindDbIpAddress and @MaxMindDbNetwork annotations, and enum conversion
is handled by @MaxMindDbCreator.

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

Co-Authored-By: Claude <noreply@anthropic.com>
All the private getX methods in DatabaseReader followed similar patterns,
so we've consolidated them into a single generic getResponse() method.
For responses that need locale transformations (City, Country, Enterprise),
we use Optional.map() to apply the transformation.

This also changes the get() method to accept an explicit caller parameter
instead of introspecting the stack trace, making error messages clearer
and more reliable.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Changed the ipAddress field type from String to InetAddress across all
model and record classes. This provides better type safety and makes it
clear that these fields contain IP addresses.

Key changes:
- Updated ipAddress field type to InetAddress in all response/record classes
- Deprecated getIpAddress() methods now call ipAddress().getHostAddress()
  to maintain backward compatibility (still return String)
- Created InetAddressSerializer to serialize InetAddress to String in JSON
- Created InetAddressDeserializer to deserialize JSON strings to InetAddress
- Created InetAddressModule and registered it globally in JsonSerializable
- Updated all tests to call .getHostAddress() when comparing IP addresses

The new ipAddress() accessor returns InetAddress, while the deprecated
getIpAddress() continues to return String for backward compatibility.

🤖 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.

1 participant