Skip to content
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

[FR] Mapping an object to multiple classes #11

Open
oxodao opened this issue Feb 6, 2024 · 0 comments
Open

[FR] Mapping an object to multiple classes #11

oxodao opened this issue Feb 6, 2024 · 0 comments

Comments

@oxodao
Copy link

oxodao commented Feb 6, 2024

Hi,

As far as I can tell, there is no way to map a single object to multiple classes, we can't use the AsMapper attribute multiple time but we also can't override / extend the method "supports".

I think it would be beneficial to have a default "supports" handler that can also have more conditions, this could be done either on the Mapper by adding another supports method, or on the MapperConfig with ExpressionLanguage that have access to the $from object to have simple conditions.

My use case is the following:
In my current software I have a generic datetime type, and I'm trying to map my object to a 3rd party API that represents them as either a date or a datetime (that's more complex than since its not just a date/datetime but a whole object). I'd rather not having a generic object that matches the structure of the API as I don't want to implement every little quirks of the 3rd parties just to satisfy my mapper, in this case I'd like to have a mapper that supports the generic object that has the "withTime" to true in a first mapper and one that has the "withTime" to false in a second mapper.

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

No branches or pull requests

1 participant