Skip to content

#3943: Allow generation of methods with a sole argument of primitive type#3944

Open
anenviousguest wants to merge 2 commits intomapstruct:mainfrom
anenviousguest:fix/3943
Open

#3943: Allow generation of methods with a sole argument of primitive type#3944
anenviousguest wants to merge 2 commits intomapstruct:mainfrom
anenviousguest:fix/3943

Conversation

@anenviousguest
Copy link

Took a stab at fixing #3943.

Not quite sure what was the reason for explicitly forbidding such methods back then, given that it works perfectly fine - at least as far as the test below is concerned.

# Conflicts:
#	processor/src/main/java/org/mapstruct/ap/internal/processor/MethodRetrievalProcessor.java
@anenviousguest
Copy link
Author

Hi @filiphr, any chance to get a feedback on this one? Thank you.

@filiphr
Copy link
Member

filiphr commented Feb 2, 2026

As you can see I've been quite busy with a lot of stuff. I kept postponing 1.7, so I wanted to do a first Beta release for it, before going deeper into other PRs. I'll get to this one.

@filiphr
Copy link
Member

filiphr commented Feb 2, 2026

One thing I would say is that if we are going to allow this, then we need to do it more proactively. It works if the target has a property named the same as the source value. However, if that's not the case, then we would treat the primitive as a bean. Therefore, I think that we need to do some adjustments in the BeanMappingMethod#build.

i.e. Can you add a test case where the target does not have a property matching the source?

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.

2 participants