I have a generic class
public MyObject<T extends SomeClass1, S extends SomeClass2> extends SomeExternalClass {
// ....
@override
public void someFunction() {
ExternalClass.doSomething(T.class); // problem here!
}
}
Inside this class, I need an object of type Class<T>
to pass it to a function of an external library. The external library expects an object of type Class<T extends SomeClass1>
as parameter.
I read about a solution to pass a Class<T>
into the constructor of my object. Unfortunately, MyObject extends a certain class, also from an external library, which has a certain constructor that will always be called - so this is no option for me.
I read about Guava, for example here: Get generic type of class at runtime
The difference to my problem is that I need an Object of type Class<T>
and not an object of type Type
.
How can I achieve this?
Thanks in advance!