-
Notifications
You must be signed in to change notification settings - Fork 67
Updating CodeTransformations to enable int/long setters/puts conversions #582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Added util class and unit tests testS
| } 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
| @@ -0,0 +1,267 @@ | |||
| /* | |||
| * Copyright 2022 LinkedIn Corp. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2025?
|
This PR can be closed as #583 replaces it |
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