Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.3
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
It looks like BasicBeanDescription throws an exception if multiple setters are found for a property:
Conflicting setter definitions for property "value": OverloadedBean#setValue(1 params) vs OverloadedBean#setValue(1 params)
I've been able to get around this limitation by subclassing BasicBeanDescription and overriding okNameForSetter to check not just for a reasonable name but also that there is a getter that has a return type the same as the setter's argument. Since okNameForSetter is called so frequently it would be much more efficient to be done only when a potential problem is detected (in BasicBeanDescription.findSetters).
Hmmh. Interesting. So basically it would be good to use conflict resolution if there is enough information to do that.
One additional question: if you explicitly specify one with @JsonProperty annotation, do you still get an exception (I suspect that would be the case).
Anyway, yes, I agree that it'd be good to improve handling for such cases; and although generally read/write sides are loosely coupled with Jackson, it would make sense to use extra information if such is available.
For what it's worth, expected work-around here would be tagging other setter(s) with @JsonIgnore.