[Java] Fix object defaults with enum properties generating invalid fluent builder expressions
Closed
NH
3mo ago+4+4+0123456789-0-0-0123456789
Fixes #24298
Added an enum case for the if statement in the method toObjectDefaultValue of the class AbstractJavaCodegen so the Java fluent builder expression generates correctly when using object defaults on an object with enum properties.
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
(For Windows users, please run the script in WSL)./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*.
IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed. - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Java:
@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08)
Summary by cubic
Fixes invalid Java fluent builder expressions for object defaults with enum properties by handling enums in AbstractJavaCodegen#toObjectDefaultValue and resolving enum class names via toEnumName. Removes a leftover debug print; generated models now reference the correct enum constants and compile.