Skip to content

refactor(generator): extract AbstractIOStage for reader/writer/cloner (C32d Step 3)#1133

Merged
jsenko merged 2 commits into
mainfrom
abstract-io-stage
Jun 29, 2026
Merged

refactor(generator): extract AbstractIOStage for reader/writer/cloner (C32d Step 3)#1133
jsenko merged 2 commits into
mainfrom
abstract-io-stage

Conversation

@jsenko

@jsenko jsenko commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • New AbstractIOStage base class with template method pattern for the shared orchestration across reader, writer, and cloner stages
  • Shared doProcess(), spec-version iteration, Roaster class creation, entity loop, property-type dispatch
  • Eliminates 3 duplicated inner classes (CreateReadPropertySnippet, CreateWriteProperty, CreateCloneProperty) — identical type dispatch logic now lives in dispatchProperty() on the base, with a createPropertyBlock(kind) factory method for subclass-specific code blocks
  • Fixes ReaderMethod/WriterMethod writeTo contract — extra context passed via constructor so Method.writeTo(JavaSource<?>) works properly

Before: 1091 lines across 3 stages. After: 694 lines (146 base + 548). Net -397 lines.

Context

C32d Step 3 in #1042.

Test plan

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

jsenko added 2 commits June 29, 2026 02:22
…, ClonerFactory (C32d Step 2d)

3 new method classes (parameterized instead of 6 separate):
- IOFactoryMethod (Reader/Writer mode) — createModelReader/Writer switch
- IODispatcherFactoryMethod (Reader/Writer mode) — dispatcher switch
- ClonerFactoryMethod — createModelCloner with unique dispatcher pattern

Factory stages now thin wrappers delegating to method classes.
Added 5 FQN methods to CodeGenContext.

Net -144 lines.
…or reader/writer/cloner (C32d Step 3)

New AbstractIOStage base class with template method pattern:
- Shared doProcess(), spec-version iteration, Roaster class creation,
  entity loop with lookup+warn, and class indexing
- Shared property-type dispatch (dispatchProperty) eliminates 3
  duplicated inner classes (CreateReadPropertySnippet, CreateWriteProperty,
  CreateCloneProperty)
- Abstract hooks: getPackageName, getClassName, addImports,
  createEntityMethod, createPropertyBlock
- Optional hooks: addInterfaceImplementation, afterEntityMethods

Also fixes ReaderMethod/WriterMethod writeTo contract — extra context
now passed via constructor so the standard Method.writeTo(JavaSource<?>)
works instead of throwing UnsupportedOperationException.

Before: 1091 lines across 3 stages. After: 694 lines (146 base + 548).
Net -397 lines, -523 insertions/deletions in diff.
@jsenko jsenko merged commit 151acea into main Jun 29, 2026
2 checks passed
@jsenko jsenko deleted the abstract-io-stage branch June 29, 2026 01:29
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