Skip to content

fix(generator): writeRoot returns JsonNode, remove unnecessary casts (C35b)#1137

Merged
jsenko merged 2 commits into
mainfrom
c35b-generated-code-cleanup
Jun 29, 2026
Merged

fix(generator): writeRoot returns JsonNode, remove unnecessary casts (C35b)#1137
jsenko merged 2 commits into
mainfrom
c35b-generated-code-cleanup

Conversation

@jsenko

@jsenko jsenko commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Three generated code cleanups:

  1. 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.

  2. Remove unnecessary List casts — WriterMethod generated (java.util.List<?>) union.asStringList() but asStringList() already returns List<String>. Removed the lossy casts.

  3. ParentPropertyKind enum holds value — enum values now store their string directly (STANDARD("standard")) instead of using a kindToString() switch.

Context

C35b in #1042.

Test plan

  • All 1129 data-models tests pass
  • Generated output compiles

jsenko added 2 commits June 29, 2026 13:34
… 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).
@jsenko jsenko merged commit 147a579 into main Jun 29, 2026
2 checks passed
@jsenko jsenko deleted the c35b-generated-code-cleanup branch June 29, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant