Basically just the opposite of this question. I want to convert a Class<T> object to a TypeReference<T> object.
I have tried:
foo(Class<T> valueType)
{
TypeReference ref = new TypeReference<T>(){};
}
but that just returns a type reference of the classes's super class. I also tried:
foo(Class<T> valueType)
{
TypeReference ref = new TypeReference<valueType>(){};
}
and
foo(Class<T> valueType)
{
TypeReference ref = new TypeReference<valueType.getRawClass()>(){};
}
But the second two don't compile. How do I do this?