-
Notifications
You must be signed in to change notification settings - Fork 32
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
Compiler Error with Qualified Mapping and Custom Converter - Duplicate Method Generation #86
Comments
Things to note here:
To sum things up, this is definitely a non-trivial issue. I'll see if I can give it some thought over the next couple of days/weeks. |
Hello @Chessray, thanks for your answer! Yes, I overlooked the Thanks, Maximiliano. |
Solution idea:
@gigena-git It's definitely intriguing, and as you can see there are a few things to consider. I can't guarantee a quick solution. Happy for you to take a head start in this yourself if you wish. 🙂 |
I agree with the approach for method name generation. Even though I'm still getting acquainted with how the MapStruct processor works, I can visualize a way in which it could be implemented.
If the processor gives every single qualified method it's own conversion service, the adapter would end up with 7 instances. However, with the given methods, only 2 are needed - as the only the The best approach - if possible - would be to determine the number of
The implementation could look something like this:
This is a brief description of what the Mapper builder should do.
Now, inside
I still have to look how would a mapper implementation call the methods with modified qualified names. |
The whole point of this module is the decoupling of Mappers. The idea is that we clone the annotations onto the generated methods so only the Adapter class shows up in the
I merely threw some quick ideas around. If there is a way to determine this for all cases automatically, then I'm certainly on board with that. |
After giving this some thought, it feels like we'd be going down a nearly bottomless rabbit hole without much gain. The idea as described so far would require several So if we always leave the service initialization to the user, there seems to be little gain in pursuing this idea. What we could rather think about is suppressing the method generation for certain cases so at least the generated Adapter passes compilation. This seems like one of the situations where you want to just use MapStruct directly and not let the Mapper extend and/or implement the |
Let say I create two classes
Source
:and
Target
:Then I create a new mapper for the two classes:
And then I create mappers for each of the two operations:
and:
Finally, I create the
@MapperConfig
:Result: Two methods with the same are passed down to
ConversionServiceAdapter
, thus creating a compiler error:Stacktrace (redacted):
Expected:
The enqine should generate two methods with different signatures, each resolving the qualifications specified with
(at)Named
.and then use them in the converter:
The text was updated successfully, but these errors were encountered: