[transactionwebhooks] Code generation: update services and models#1782
[transactionwebhooks] Code generation: update services and models#1782AdyenAutomationBot wants to merge 1 commit intomainfrom
Conversation
Summary of ChangesHello, 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 updates the generated code for the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request, which appears to be auto-generated, updates the transaction webhook models. The main changes include renaming the package from com.adyen.model.transactionwebhooks to com.adyen.model.java, removing the TransactionWebhooksHandler class, and introducing a new mechanism across all model classes to support explicit null value serialization in JSON.
My review has identified two main points. Firstly, the PR introduces significant breaking changes by renaming packages and removing a public class. These changes should be clearly communicated in the PR description to inform users about the necessary migration steps. Secondly, the new implementation for explicit null serialization introduces a considerable amount of duplicated code across the model classes. I've suggested a refactoring approach using a common base class to improve maintainability.
| */ | ||
|
|
||
| package com.adyen.model.transactionwebhooks; | ||
| package com.adyen.model.java; |
There was a problem hiding this comment.
This PR introduces significant breaking changes:
- The package for all model classes has been changed from
com.adyen.model.transactionwebhookstocom.adyen.model.java. - The public class
TransactionWebhooksHandlerhas been removed.
These changes will require users of the library to update their code. It would be very helpful to clearly document these breaking changes in the pull request description, along with guidance on how to migrate. For example, what is the new recommended way to handle transaction webhooks now that TransactionWebhooksHandler is gone?
| // add to map when value is null | ||
| private void addIfNull(Map<String, Object> map, String key, Object value) { | ||
| if (value == null) { | ||
| map.put(key, null); | ||
| } | ||
| } |
There was a problem hiding this comment.
This helper method addIfNull, along with the includeNullValues field and its associated methods (includeNullValues, isIncludeNullValues, setIncludeNullValues), are duplicated across multiple model classes in this PR. This introduces a lot of code duplication, making future maintenance harder.
Consider extracting this common functionality into a shared base class. This would centralize the logic for handling explicit null serialization, improving maintainability and reducing code redundancy. Since this code is auto-generated, this feedback is likely for the team maintaining the code generator.
For example, you could have a base class like this:
public abstract class AbstractAdyenModel {
@JsonIgnore
private boolean includeNullValues = false;
// Using generics for a fluent interface in subclasses
@SuppressWarnings("unchecked")
public <T extends AbstractAdyenModel> T includeNullValues(boolean includeNullValues) {
this.includeNullValues = includeNullValues;
return (T) this;
}
public boolean isIncludeNullValues() {
return includeNullValues;
}
public void setIncludeNullValues(boolean includeNullValues) {
this.includeNullValues = includeNullValues;
}
protected void addIfNull(Map<String, Object> map, String key, Object value) {
if (value == null) {
map.put(key, null);
}
}
@JsonInclude(JsonInclude.Include.ALWAYS)
@JsonAnyGetter
public abstract Map<String, Object> getExplicitNulls();
}Then, model classes like Amount could extend AbstractAdyenModel and override getExplicitNulls().
This PR contains the automated changes for the
transactionwebhooksservice.The commit history of this PR reflects the
adyen-openapicommits that have been applied.