35 split up serviceutils in generic and jdk http specific parts#64
Conversation
tomsontom
left a comment
There was a problem hiding this comment.
Overview
Clean refactor that splits the monolithic ServiceUtils into two well-named classes:
BaseUtils— transport-agnostic: request body encoding, URL/ASCII encoding,URLSearchParams,toHeadersJDKHttpClientResponseUtils— JDK HTTP client specific: response body parsing, error-response-to-string
The rename/split clearly communicates the responsibility of each class. The java-base/ location for the shared content generator is a good forward-looking structure.
Issues
Must Fix
1. Unused model parameter in generateBaseUtilsContent
packages/cli/src/java-base/base-utils.ts declares model: MResolvedRSDModel but never references it — the function only calls fqn() and returns a static toNodeTree(). Remove it from both the signature and the two call sites (generateBaseUtils in base-utils.ts and generator.ts).
2. Wrong config type in java-base/
generateBaseUtilsContent accepts JavaRestClientJDKGeneratorConfig but the only field it actually uses is rootPackageName. Placing a JDK-specific type in java-base/ (which is meant to be shared) ties the abstraction to one transport. Either narrow the argument to { rootPackageName: string } (or a shared base config type) or move the function into java-rest-client-jdk/.
Should Fix
3. Indentation inconsistency in generated BaseUtils.java
The template in java-base/base-utils.ts uses 4-space indentation inside the raw toNodeTree() template string, so the fixture BaseUtils.java is emitted with spaces. Every other generated file in this package (including the newly renamed JDKHttpClientResponseUtils.java) uses tabs. Align to tabs to match the project standard.
Minor
4. Missing newline at end of BaseUtils.java
The diff shows \ No newline at end of file. Trivial, but inconsistent.
Positive notes
- The conceptual split is correct and well-executed.
- All service impls are consistently updated — no stragglers left referencing
ServiceUtils. generator.tswiring is clean;generateBaseUtilsis appended at the right point.- Separating the 54%-similar
response-utils.tsfrom the oldservice-utils.tsmakes each file's purpose obvious.
No description provided.