class A<B> {
...
}
Class<A<B>> a = Class.forName(A.class.getTypeName()) throws error
a.getDeclaredConstructor(String.class).newInstance("hello world")
what should I do to make an Instance for this class?
I want to know how I can make class Name with generic type this example does not work
other example
public class SimpleTest {
interface TakePhoto<B> {
TakePhoto<B> clickShutter();
B done();
}
public @interface Specific {
String value();
}
@Specific("GALAXY-S5")
static class GalaxyS5TakePhoto<B> implements TakePhoto<B>{
B backPage;
GalaxyS5TakePhoto(B backPage){
this.backPage = backPage;
}
@Override
public TakePhoto<B> clickShutter() {
//...
return this;
}
@Override
public B done() {
return backPage;
}
}
@Test
public void Test() {
// if a Device is Galaxy S5, I want to make GalaxyS5TakePhoto
// if the device is other I will have other class models and make its instance
// I have package of these classes and want to make right instance.
// first collect specific classes which have TakePhoto
// then find and filter specific model
// then create new Instance
}
}
I just want to make class with Generic type
first collect specific classes which have TakePhoto then find and filter specific model then create new Instance