'is there any way to generate ParameterizedTypeReference Instance of generic type?

I have classes like this

class SomeWrapper<T> {
 private int code;
 private T value;
}
class SomeValue<T> {
 private String name;
 private T target;
}

So, I want to send some http request using RestTemplate in Spring. I need ParameterizedTypeReference Object like this

new ParameterizedTypeReference<SomeWrapper<SomeValue>>();

but In my case, type of SomeValue class is changable so I want to make some class like Facotry for example like this way)

ParameterizedTypeReference<SomeWrapper<SomeValue>> ptr = SomeFacotory.getParameterizedType(SomaValue.class);

is there any way to do like this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source