-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mapping from Enum to String - error (Cannot map to final type) #99
Comments
This represents one of the limitations of ModelMapper (and any library that proxies types), where we cannot proxy Enums since they're marked as final. The solution is to create your mapping such as this:
|
I have a similar problem where the source type in my case in an enum called
|
map(source.getStatus()).setStatus(null); not work how can i fix it? |
I have the same problem described here. MM version: 0.7.5 |
I have the same problem,who fix it? |
I too have the same problem. Is there any solution to this? |
Only way I could get around it in my scenario was to create a Converter<EnumSourceType, EnumDestType> like:
And then specify the conversion in the PropertyMap<SourceObject, DestObject> as:
|
I am facing this issue even for all (not only enums all data types ) mismatch types , no matter how I configure mappings I end up getting same exception
I see that in the the generated model of my pojo builders are marked as final .
pom.xml for codegen of proto files
how I do mismatch configuration
|
This worked for me |
@rana2884 thanks, your solution worked for me too. |
Sorry for doing necromancy here, but I am facing quite the same issue. Thanks to comments here I managed to get my bundle up and running, but I think I need a little explanation:
With this line of code I will end up with |
Hi @AloisSeckar,
Correct, as the
As setters, like the (this "final type" issue is similar to #391 ) |
Hi,
I am trying to map two objects, where the source has an Enum as property and the respective property in destination is of String type.
The properties are mapped correctly, but I receive (Cannot map to final type) error.
I am using 0.6.3 version of the model mapper. The issue seems to be present in 0.6.4 as well.
As you can see from the code snippet, I have tried using Converter as well, but that didn't help much either.
The relevant code is below.
The error is as follows:
Any help will be greatly appreciated.
The text was updated successfully, but these errors were encountered: