Jackson Serializer Register SimpleModule with Generics

Viewed 4254

I have this class

public class ResultList<T> {......}

and my JsonSerializer class

public class ListProductSerializer extends JsonSerializer<ResultList<Product>> {..}

How do register the SimpleModule in the ObjectMapper

this not work

MAPPER.registerModule(new SimpleModule()
                .addSerializer(ResultList.class, new ListProductSerializer()));

i get this error

Error:(67, 17) java: method addSerializer in class com.fasterxml.jackson.databind.module.SimpleModule cannot be applied to given types;
  required: java.lang.Class<? extends T>,com.fasterxml.jackson.databind.JsonSerializer<T>
  found: java.lang.Class<com.onkalo.rest.json.wrapper.ResultList>,com.onkalo.rest.json.serializer.ListProductSerializer
  reason: cannot infer type-variable(s) T
    (argument mismatch; java.lang.Class<com.onkalo.rest.json.wrapper.ResultList> cannot be converted to java.lang.Class<? extends com.onkalo.rest.json.wrapper.ResultList<com.onkalo.service.domain.Product>>)
1 Answers
Related