[REQ][Java] useRecords beyond Spring: shared logic and the java client
#10490 asks for Java models as records. useRecords for Spring is on master for 7.27.0, with allOf open in #25492. I'd like to offer the same option in the java client: restclient, webclient and native first, okhttp-gson last, one library per PR.
flowchart LR
H["record decision in one helper"] --> S["spring: on master"]
H --> J["java client: library by library"]
The first PR only moves that decision out of SpringCodegen, and regenerating the samples must change no file; the other Java generators never reach it. Gson is untried, and if this doesn't fit, useRecords stays Spring-only. @martin-mfg @KannaKim @Zomzog, go or no-go before I start?
This sounds like a good update to me. Do you have any thought on this @wing328
A small improvement: Add java 17 support to JavaFileAssert. This can be done by upgrading javaparser-core to 3.28.2. in JavaFileAssert:
public static ParserConfiguration JAVA_17 = new ParserConfiguration().setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_17);
public static JavaFileAssert assertThat(ParserConfiguration parserConfiguration, final Path path) {
ParserConfiguration oldParserConfiguration = StaticJavaParser.getParserConfiguration();
try {
StaticJavaParser.setConfiguration(parserConfiguration);
return new JavaFileAssert(StaticJavaParser.parse(path));
} catch (IOException | ParseProblemException e) {
throw new RuntimeException("Exception while reading file: " + path, e);
} finally {
StaticJavaParser.setConfiguration(oldParserConfiguration);
}
}
public JavaFileAssert isRecord() {
Assertions.assertThat(actual.getType(0).asClassOrInterfaceDeclaration())
.withFailMessage("Expected type %s to be a record", actual.getType(0).getName().asString())
.extracting(ClassOrInterfaceDeclaration::isRecordDeclaration)
.isEqualTo(true);
return this;
}
@wing328 KannaKim, from the Java and Spring committees, supports this above. Should I go ahead with the shared logic and the java client, one library per PR with default output unchanged, or keep records Spring-only?
@wing328 thanks for merging #25501 and #25641. Should I go ahead with records beyond Spring: the shared logic in AbstractJavaCodegen, then the java client one library per PR, default output unchanged? #25492, the allOf step for Spring records, is ready for review as well.
Should I go ahead with records beyond Spring: the shared logic in AbstractJavaCodegen, then the java client one library per PR, default output unchanged?
yes please