I've got a class somewhat like this:
public class Test {
private final List<ISomeType> things = new LinkedList<ISomeType>();
public <T extends ISomeType> Test(Class<T> clazz, int order) {
for (int i = 0; i < order; i++) {
try {
this.things.add(clazz.newInstance());
} catch (Exception e) {
// stackoverflowers use your imagination
}
}
}
}
Where I expect and hope the Class clazz has an accessible no-argument constructor. Is there any way I can enforce presence of it at compile time?