Reputation: 10843
Consider this class structure.
class Class1<T> {
Class2<T> field1;
}
If I have a ParameterizedType
instance representing Class1<String>
through reflection, how can I get/create a ParameterizedType
instance representing Class2<String>
?
Upvotes: 0
Views: 229
Reputation: 122439
ParameterizedType
is an interface. Simply write a class that implements it (or copy some existing implementation from the Internet) so that its methods return what you want.
Upvotes: 1
Reputation: 6181
In its current state the reflection API allows for (limited) inspection of generic type information. Since one could not leverage the newly constructed ParameterizedType
there is little point in allowing its construction in the first place.
If you are building an API accepting ParameterizedType
s and need users to construct their own, you might consider switching to guava's TypeToken
-Class instead.
Upvotes: 0