refactor: Json to proto message refactoring#2085
Conversation
| .toFormatter() | ||
| .withZone(ZoneOffset.UTC); | ||
| private final String ROOT_JSON_SCOPE = "root"; | ||
| private final boolean DONT_ACCEPT_UNKNOWN_FIELDS = false; |
There was a problem hiding this comment.
It is a bit strange to have this constant. I think it is easier to read just to keep the bollean.
There was a problem hiding this comment.
Are you sure? It explicitly names the intention. Otherwise you may mix boolean values:
return convertToProtoMessage(protoSchema, null, json, "root", true, false);
Can you tell what is true and false here? Your IDE will probably help you here, but what about GitHub review? Are you sure you won't put topLevel value in place of ignoreUnknownArguments parameter?
There was a problem hiding this comment.
Usually we will just annotate the parameters with the argument name. So it is just:
protoSchema,
tableSchema.getFieldsList(),
json,
"root",
/topLevel=/ true,
/ignoreUnknownFields/ false);
There was a problem hiding this comment.
DONT_ACCEPT_UNKNOWN_FIELDS and ROOT_JSON_SCOPE. Thanks.
| @@ -25,13 +25,11 @@ | |||
| import com.google.protobuf.Descriptors.Descriptor; | |||
There was a problem hiding this comment.
Thanks for improving the code!
Could you provide a list of things refactored in the PR description?
b832cd7 to
abea73c
Compare
…d remove usage of soon deprecated (Java 9) Long constructor
…ToProtoMessage and use primitives for booleans
…sonToProtoMessage repeated fields.
abea73c to
ef24980
Compare
… in JsonToProtoMessage
ef24980 to
009ced0
Compare

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Changes:
refactor: Use equalsIgnoreCase for JSON string boolean values in JsonToProtoMessage and use primitives for booleans
refactor: Use enhanced for in JsonToProtoMessage
refactor: Properly reference to static field INSTANCE in JsonToProtoMessage
refactor: Remove unnecessary LOG field from JsonToProtoMessage
refactor: Remove unnecessary casts from JsonToProtoMessage methods and remove usage of soon deprecated (Java 9) Long constructor
refactor: Remove unnecessary variables "message" from JsonToProtoMessage methods
refactor: Remove topLevel parameter from JsonToProtoMessage methods
refactor: Extract magic variables to constants
refactor: Capitalize deep constants in JsonToProtoMessage and make them final
Fixes #2042 ☕️
If you write sample code, please follow the samples format.