[Java][Spring] useRecords: a model whose annotations would clash on a component stays a class

Merged
SE
3d ago
+320-2

record.mustache puts everything a class spreads over a field, a getter and a setter on one component, so an x-field-extra-annotation of @JsonProperty beside the generated one, or two @JsonView in the getter and setter extensions, stopped compiling with useRecords. Such a model now stays a class and logs the reason, as the option promises. Every other model generates the same output.

@cachescrubber @welshm @MelleD @atextor @manedev79 @javisst @borsch @banlevente @Zomzog @martin-mfg @KannaKim

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    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.

Summary by cubic

Keeps a model a class under useRecords when property annotations would clash on one record component, so generation no longer produces code that fails to compile.

  • Compares the annotation names of x-field-extra-annotation, x-extra-annotation, and x-setter-extra-annotation against each other and against the annotations the templates write for the active options, then logs the property and annotation that clash.
  • Fixes a stack overflow when an extra annotation name has thousands of dotted segments.