Skip to content

#4000 Fix property name resolution for fluent setters whose second character is upper case#4074

Open
BK202503 wants to merge 1 commit into
mapstruct:mainfrom
BK202503:issue/4000-camelcase-fluent-setter
Open

#4000 Fix property name resolution for fluent setters whose second character is upper case#4074
BK202503 wants to merge 1 commit into
mapstruct:mainfrom
BK202503:issue/4000-camelcase-fluent-setter

Conversation

@BK202503

Copy link
Copy Markdown

Fixes #4000.

DefaultAccessorNamingStrategy.getPropertyName(...) returns the raw method name as the property name for fluent setters that do not start with set (e.g. Lombok @Builder style). For methods whose second character is upper case, this conflicts with how the JavaBean accessor side resolves the same property:

Side Method Existing property name
Source (JavaBean) getXNameField() XNameField (via Introspector decapitalize, both first chars upper case → kept)
Target (fluent setter) xNameField(...) (Lombok @Builder) xNameField (raw method name)

The two property names differ, so the target field is silently skipped and a user-supplied @Mapping(target = "xNameField", source = "XNameField") with a capitalized source is required to work around it.

This PR applies the same JavaBean-style decapitalization to fluent setters: xNameField → capitalize first char → XNameFielddecapitalizeXNameField. Ordinary fluent setters whose second character is lower case (settlementDate(...)) are unaffected (SettlementDatesettlementDate).

Test

Added Issue4000Test modelled after Issue1799Test, with a source class exposing getXNameField() and a target class with a Lombok-style Builder.xNameField(...) fluent setter.

Regression

Ran the builder / superbuilder / _1799 test suites locally (82 tests) - all passing. Full processor suite was not run locally; CI will exercise it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Camelcase fields where the second letter is capitalized are not picked up

1 participant