Skip to content

mapstruct#3836 sealed interface create impl class with switch#3885

Open
mildw428 wants to merge 4 commits intomapstruct:mainfrom
mildw428:main
Open

mapstruct#3836 sealed interface create impl class with switch#3885
mildw428 wants to merge 4 commits intomapstruct:mainfrom
mildw428:main

Conversation

@mildw428
Copy link

I've fixed it for bug number 3836.

I added sourceArgumentType to know the parameter type of the subclass.

Generates as a switch or if-else syntax according to isSealed().

If you have any issues, please advise.

#3836

@mildw428
Copy link
Author

In version 17, the switch statement needs a default return, resulting in an error. If anyone has any branching ideas based on the version, please let me know.

@filiphr
Copy link
Member

filiphr commented Jun 15, 2025

I'll need some time to go through this one @mildw428. I am not sure that we can always use the enhanced switch. We can only do that if the type is correctly sealed otherwise we need a fallback.

@mildw428
Copy link
Author

I'll need some time to go through this one @mildw428. I am not sure that we can always use the enhanced switch. We can only do that if the type is correctly sealed otherwise we need a fallback.

Thank you for reviewing my code.

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