You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Field-aware member ordering in generated builders #328
Methods in generated builders currently sort only by a global ordering bucket, then name, then signature. Grouping all direct setters at the end of the fluent section (done in #325 so MapStruct's last-wins accessor resolution binds the real setter) disconnected each field's methods: name(String) no longer sits next to name(Supplier), nameUpdate, add2Nicknames, etc.
Proposal: full member ordering
Order generated members by:
Constructors first
Access modifier — public before non-public
Scope — static members last
Field — methods belonging to the same bean field stay together (fields in a stable order, e.g. alphabetical as in the class-javadoc example chain)
Name — within a field, overloads of one name stay adjacent
Existing intra-name tie-breaks (parameter count, generic vs non-generic, signature)
With this layout each field's cluster reads naturally (name(String), name(Supplier), name(String,Object...), nameUpdate(...), add2Name(...)) while still guaranteeing the direct setter is the last overload of its name — which keeps #300's MapStruct binding working without the all-setters-at-the-end tradeoff.
Precedent
The class-javadoc example chain already groups exactly this way: fields alphabetical, each field's calls in a deterministic order (BuilderJavadocExampleTest asserts .pages(...), then .tags(...), then .title(...)). The member ordering would align the emitted class with what the javadoc already presents.
Implementation notes
MethodDto today deliberately carries no field-origin metadata — the comparator would need a field/group key (populated in BuilderToGenerationTypeMapper from BuilderMethodDto.sourceFieldName), or a redesigned comparator in the rendering layer.
Activity