I have class with Class<?>
field. I have a method, which has to cast string to object with help of Jackson.
private Class<?> myType = ...;
private String jsonRepresentationOfObject = ....;
ObjectMapper mapper = new ObjectMapper();
public <T> T get() {
return mapper.readValue(jsonRepresentationOfObject, myType);
}
Is there any possibility to cast myType
to T
? Or it is impossible, because of type erasure?