DozerMapper/dozer — pull request #163 by STRiDGE (2014-04-23 23:45:07+00:00)
Title: Do not force "get" and "put methods when using Map

Allow custom map-set and map-get methods to be defined even when using a subclass of *java.util.Map*. If no *mapGetMethod* is defined, default to "get". If no *mapSetMethod* is defined, default to "put".

This was a requirement for us because we created a subclass of *java.util.Map* with a bunch of overloaded *put()* methods that did a sanity checking and/or conversion. The put method was deprecated to force typed methods to be used. We also added a *putUnknownType(String, Object)* method that had a few instanceof checks and then called the required put method for the discovered type.

When we ran this through Dozer, it would work mostly in the JUnit test (picked up deprecated *put(String, Object)* method) but it failed in our integration test because it picked up a different version of the *put* method (most of the time it was *put(String, Double)* )

Since the *MapPropertyDescriptor* had no knowledge of the destination type, we could not change the *getWriteMethod* method to look for a specific overloaded version of the setMethod. And *Class.getMethods* return the methods in an unspecified order.

So we tried the custom map-set-method path. But it seemed to have no effect. Which is when we realized our configuration property was being overridden because of the *isMapProperty* flag in *PropertyDescriptorFactory*.

We have implemented this change locally and it meets all our requirements. If anybody else has the same problem, this will work for them as well.

I do not foresee any problems added by this change, except maybe for when you are using a custom map and did not provide a get/set method it will now default to "get"/"put", which might cause a MethodNotFoundException.