-
Notifications
You must be signed in to change notification settings - Fork 9
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
Custom MapType #146
Comments
Actually it seems like a |
In mapWrapper, you can create an instance of Mappr. There could be cases where different mappers would be used to map output, so passing instances does not make sense. However, allowing the creation of a 'custom' MapType for whole objects is something we did not think about. We can introduce a special factory version of If inside What do you think @tenhobi ? |
I already started implementing a small poc because as I said I'm dependant on this feature. I settled on the first parameter just being an |
Actually creating instances might be fine considering the reduced overhead in the generator. I actually didn't think of that initially probably because it's too easy haha. Guess I'll just implement a |
Agree. MapType.custom can be added, but access to this/other mapprs is probably easier to do inside that function. |
I have the use case that I need to define a custom mapping function for an entire object. The problem is that this Object has inner objects which can be "automatically" mapped by other MapType definitions.
My proposed solution would be to dynamically inject an instance of the mapper into the custom convert function. This could be done for both a new
MapType.custom
but also the existing custom conversion functions inTypeConverter
s andField.custom
s. The idea would be to "detect" that the provided function takes in two parameters instead of one e.g. when looking atField.custom
not only acceptingTarget Function(Source dto)
but alsoTarget Function(MapprInstance mappr, Source dto)
.A full example of this imaginary syntax could look like this:
I'd be open to implement this feature because unless I overlooked some existing feature to handle my use case I am kinda dependent on a solution :D
The text was updated successfully, but these errors were encountered: