I\'m trying to write a custom deserializer for Jackson and I want to make it generic (generic in the sense of working on any type, not as in \"generics\").
However I
I have solved my particular problem by adding an implementation of Deserializers to the ObjectMapper. Eg
Deserializers d = new Deserializers.Base() {
@Override
public JsonDeserializer> findEnumDeserializer(Class> type, DeserializationConfig config, BeanDescription beanDesc, BeanProperty property)
throws JsonMappingException {
if (property.getType().getContentType() != null)
return new EnumDeserializer(property.getType().getContentType().getRawClass());
return new EnumDeserializer(property.getType().getRawClass());
}
};
mapper.setDeserializerProvider(mapper.getDeserializerProvider().withAdditionalDeserializers(d));
This will return my custom EnumDeserializer instantiated for each separate Enum type.