fix(generator): writeRoot returns JsonNode, remove unnecessary casts (C35b)#1137
Merged
Conversation
… enum value (C35b) - writeRoot now returns JsonNode instead of ObjectNode, so boolean schema roots serialize correctly instead of returning null - Remove unnecessary (java.util.List<?>) casts in WriterMethod — union asXyzList() methods already return typed lists - ParentPropertyKind enum now holds its string value directly instead of using a kindToString() switch
…reader cleanup (C35b) - Clear methods use Any type instead of Object+Node cast (detach is on Any) - New DataModelUtil.setParent/setParentMap consolidates 3-4 NodeImpl/UnionValueImpl cast+call lines into a single utility call. Reduces generated Impl classes significantly. - Remove redundant null check in union reader dispatch (bottom return null suffices) - Remove unnecessary (RootCapable) cast in readRoot — union root types extend RootCapable Net -323 lines in generated code (synthetic snapshots).
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
Three generated code cleanups:
writeRoot returns JsonNode — was returning ObjectNode and silently returning null for boolean schema roots. Now returns JsonNode so union roots (like
JsonSchema = boolean|FullSchema) serialize correctly.Remove unnecessary List casts — WriterMethod generated
(java.util.List<?>) union.asStringList()butasStringList()already returnsList<String>. Removed the lossy casts.ParentPropertyKind enum holds value — enum values now store their string directly (
STANDARD("standard")) instead of using akindToString()switch.Context
C35b in #1042.
Test plan