refactor(generator): extract AbstractIOStage for reader/writer/cloner (C32d Step 3)#1133
Merged
Conversation
…, 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.
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
AbstractIOStagebase class with template method pattern for the shared orchestration across reader, writer, and cloner stagesdoProcess(), spec-version iteration, Roaster class creation, entity loop, property-type dispatchCreateReadPropertySnippet,CreateWriteProperty,CreateCloneProperty) — identical type dispatch logic now lives indispatchProperty()on the base, with acreatePropertyBlock(kind)factory method for subclass-specific code blocksReaderMethod/WriterMethodwriteTocontract — extra context passed via constructor soMethod.writeTo(JavaSource<?>)works properlyBefore: 1091 lines across 3 stages. After: 694 lines (146 base + 548). Net -397 lines.
Context
C32d Step 3 in #1042.
Test plan