Allow user customized MappingStrategies #142
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I ran into a situation where I needed to write my own MappingStrategy. I was able to implement this in the current release, but it is not very clean. It required extending DefaultMapperFactory and MapperFacadeImpl. It would be nice if I could define and inject my own MappingStrategy without so much trouble.
I wrote up a quick implementation of my line of thinking. Each MappingStrategy type has a factory, which knows if its strategy can be applied to the requested mapping, and it can create the strategy for the mapping.
When a strategy is required, the system will query each registered factory (user defined first, then default factories). The first factory that can take the job will produce the strategy.
If this looks like a feature you would be interested in adding, and this implementation is acceptable, I can clean it up, add documentation and testing.