java - Jackson mapping fails for generics passed as parameter -


i have common api different entity rest api. below method getting list of entities (groovy).

class commonrestapi<t>{  commonrestapi(){         } .... list<t> getentities(class<t> clazz) {     clientresponse response = some_rest_get //works fine     t[] entities     if (response.status == 200) {         try{             generictype<responsewrapper<t[]>> type = new generictype<responsewrapper<t[]>>(){} //here error              entities = response.getentity(type).getdata()         }catch(exception e){             log.debug e.getmessage()         }     }     else {         log.debug("status code: " + response.status)     }     return arrays.aslist(entities) } } 

responsewrapper class (java):

public class responsewrapper<t> {  private t data;  public t getdata() {     return data; }  public void setdata(t data) {     this.data = data; } } 

and calling method with:

 commonrestapi.getentities(mydomain.class) 

here rest api returns data mapping pojo not work. error message just: null. can tell me if possible @ all. if yes please give me guidance. note: common api class in groovy

i think issue can't instantiate generics

new generictype<responsewrapper<t[]>>(){} 

fails same reason that

new t[10]; 

would fail. type t erased compiler, , not exist @ runtime.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -