Skip to content

Conversation

@kabir
Copy link
Collaborator

@kabir kabir commented Dec 17, 2025

Getter signatures are now changed.

Errors are not converted since they need to extend RuntimeException etc. Similarly the Request/Response objects are not converted either, as we are evaluating moving them out of the spec package. However, first we need to double check if they are still used in the client facing API.

Fixes #507 🦕

Replaces: #509

Getter signatures are now changed.

Errors are not converted since they need to extend RuntimeException etc.
Similarly the Request/Response objects are not converted either,
as we are evaluating moving them out of the spec package.
However, first we need to double check if they are client facing API.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kabir, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly modernizes the codebase by refactoring numerous domain classes into Java records. This change streamlines data access patterns, enhances immutability, and reduces boilerplate code, leading to cleaner and more maintainable code. The update required extensive modifications across client, server, and test modules to adapt to the new record accessor syntax, ensuring consistency and leveraging modern Java features.

Highlights

  • Domain Class Unification: Several core domain classes within the spec package, including APIKeySecurityScheme, DataPart, FilePart, HTTPAuthSecurityScheme, Message, MutualTLSSecurityScheme, OAuth2SecurityScheme, OpenIdConnectSecurityScheme, Task, TaskArtifactUpdateEvent, TaskStatusUpdateEvent, and TextPart, have been refactored into Java records. This change simplifies these data-carrying classes by automatically generating boilerplate code like constructors, getters, equals(), hashCode(), and toString() methods.
  • Getter Signature Changes: As a direct consequence of converting to records, all getter method signatures have changed from the traditional getFieldName() style to the more concise fieldName() accessor style. This impacts numerous files across the codebase where these domain objects are accessed.
  • Immutability Enhancements: The conversion to records inherently promotes immutability for these domain classes, making them safer for concurrent use and easier to reason about. Defensive copying has been applied where necessary for collections within records (e.g., Message parts, Task history and artifacts).
  • Selective Conversion: Error classes and Request/Response objects were intentionally not converted to records. Error classes need to extend RuntimeException, which is not compatible with records. Request/Response objects are currently being evaluated for potential relocation outside the spec package, pending a review of their client-facing API usage.
  • Serialization Workaround: A temporary workaround has been implemented in JsonUtil.java to explicitly add the kind field during JSON serialization for Part and StreamingEventKind objects. This addresses a current limitation and is tracked for a more permanent fix in issue [Feat]: Remove 'kind' field discriminator #544.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a great step towards modernizing the codebase by converting many of the spec domain classes to Java records. The changes are extensive and have been applied consistently across the codebase, including updating all call sites to use record accessors instead of getters. The move to immutable records improves the robustness and clarity of the domain model. The review identified a minor issue in a test file where an assertion became redundant after the refactoring. Overall, this is a high-quality refactoring.

@kabir kabir merged commit 487cd46 into a2aproject:main Dec 17, 2025
11 checks passed
@kabir kabir deleted the spec-records branch December 17, 2025 14:09
kabir added a commit to kabir/a2a-java that referenced this pull request Dec 23, 2025
Getter signatures are now changed.

Errors are not converted since they need to extend RuntimeException etc.
Similarly the Request/Response objects are not converted either, as we
are evaluating moving them out of the spec package. However, first we
need to double check if they are still used in the client facing API.

Fixes a2aproject#507 🦕

Replaces: a2aproject#509
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat!]: Use records for immutable objects in the spec API

2 participants