Skip to content

Conversation

@gcatanese
Copy link
Contributor

@gcatanese gcatanese commented Dec 9, 2025

This PR adjust the approach implemented in #1603, by skipping the generation of the code that handles the nullable properties in case of Webhook classes (as there is no need to handle nullable attributes).

The Mustache templates have been updated to check if the additionalData handleNullableProperties is set by the SDK Automation Bot (see PR). The flag is only set for models that belong to an API.

In a second commit I have corrected the implementation of hashCode and equals, to include the new attributes that the generation now includes.

This PR also generates the Recurring API models.

@gcatanese gcatanese requested a review from a team as a code owner December 9, 2025 14:38
@gcatanese gcatanese added the Enhancement Indicates new feature requests label Dec 9, 2025
@gcatanese gcatanese requested a review from a team as a code owner December 9, 2025 14:38
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @gcatanese, 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 introduces a targeted optimization to the code generation process, specifically for Java models. It ensures that boilerplate code for handling nullable properties is only generated when necessary, primarily for API models, thereby streamlining webhook-related classes and improving overall code efficiency and clarity.

Highlights

  • Optimized Nullable Property Handling: The pull request refines the handling of nullable properties by skipping code generation for them specifically within Webhook classes, where such handling is not required.
  • Template Logic Update: Mustache templates have been updated to conditionally generate nullable property handling code. This is now controlled by an handleNullableProperties flag, which is only set for API models, not Webhook models.
  • Explicit Null Serialization: Model classes now include mechanisms to explicitly serialize null values when desired. This involves adding isSet<Property> boolean flags for each property, an includeNullValues flag, and corresponding methods (includeNullValues, isIncludeNullValues, setIncludeNullValues, getExplicitNulls, addIfNull) to manage this behavior.
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 introduces a mechanism for handling explicit null serialization in the generated model classes. This is done by adding isSet... flags for each property and using a custom serialization logic with @JsonAnyGetter. The changes are conditionally applied based on a handleNullableProperties flag in the Mustache template.

While the overall approach is sound, I've found a significant issue: the equals() and hashCode() methods in the generated classes are not updated to account for the new isSet... flags. This breaks the equals contract, as objects that are considered equal can produce different JSON representations. I've left comments on how to address this in both the template and one of the generated classes. This issue is critical for ensuring the correctness of collections and other logic that relies on object equality.

@gcatanese gcatanese requested a review from galesky-a December 10, 2025 08:32
@gcatanese gcatanese merged commit b6b004f into main Dec 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Indicates new feature requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants