I have a generic class. It has a method which deserializes an object and returns it:
public class MyClass<T> {
T storage;
private T get() throws InterruptedException {
T clone=gson.fromJson(storage,myclass); //not working
return clone;
}
}
My problem is that fromJson requieres a Class as second parameter. How can I get it from my Type T? Is there a generic implementation of fromJson?
EDIT: is there a generic implementation of Gson how to avoid this constructur (mentioned in the question) for getting the class?