Updating CodeTransformations to enable int/long setters/puts conversions #582
Open
li-enguyen wants to merge 15 commits intolinkedin:masterfrom
Open
Updating CodeTransformations to enable int/long setters/puts conversions #582li-enguyen wants to merge 15 commits intolinkedin:masterfrom
li-enguyen wants to merge 15 commits intolinkedin:masterfrom
Conversation
added 5 commits
May 22, 2025 14:03
added 7 commits
June 3, 2025 14:08
Added util class and unit tests testS
bipinparmar
reviewed
Jun 12, 2025
| } else if ("long".equals(fieldType)) { | ||
| overloadSignature = "public void " + methodName + "(int "; | ||
| } else if (JAVA_LANG_INTEGER.equals(fieldType)) { | ||
| overloadSignature = "public void " + methodName + "(java.lang.Long "; |
There was a problem hiding this comment.
Have you tried
public void setMemberId(java.lang.Integer i)
public void setMemberId(java.lang.Long l)
And the MP has
int memberId=5;
setMemberId(memberId);
Will the right method be called or would there be a runtime error because two methods can support the value 5
Collaborator
Author
There was a problem hiding this comment.
I did a quick unit test for this: In this case, the setMemberId(java.lang.Integer i) method will be called, since the memberId is int. int will not get auto boxed into a Long in java
li-ukumar
reviewed
Jun 26, 2025
| @@ -0,0 +1,267 @@ | |||
| /* | |||
| * Copyright 2022 LinkedIn Corp. | |||
Contributor
|
This PR can be closed as #583 replaces it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary: Updating CodeTransformations to modify generated java code to enable conversions between ints and long fields.
Changes:
enhanceNumericPutMethod: update public void put(int field$, java.lang.Object value$) method to allow setting int/Integer fields using long/Long objects, and vice versaaddOverloadedNumericSetterMethods: add overloaded setters to allow setting Int/Integer fields using long/Longs and vice versaaddOverloadedNumericConstructor: add overloaded constructor methods to allow int field to be set using long param, and vice versaaddOverloadedNumericBuilderSetterMethods: add overloaded setters for builder classjava file before change avro1_10
java file after change avro1_10
java file before change avro1_4
java file after change avro1_4
java file before change with builder
java file after change with builder