I'm not sure if this is possible, but I'd like to have an overloaded setter on a Jackson deserializable object. So that depending on the object in that field it deserializes differently.
Example
public class Thing {
private MyObject1 object;
public MyObject1 getObject() {
return object;
public void setObject(MyObject1 object) {
this.object = object;
}
public void setObject(MyObject2 object) {
this.object = translate1To2(object);
}
}
If this is not possible, would someone offer me an alternative approach? My concern is that in the simple case where there is only one setter, Jackson doesn't have to choose which object to deserialize the JSON as, so not sure if it even can.
UPDATE: The above gives a com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "object"
as is.