I want to pass a Class
as parameter and return an instance of this class. I need ensure that the class implements ISomeInterface
. I know I can do it with reflection:
Object get(Class theClass) {
return theClass.newInstance();
}
What I do not know is how to ensure that theClass
implements ISomeInterface
ISomeInterface get(Class<? extends ISomeInterface> theClass) {...}
// errrr... you know what i mean?
I don't like reflection in production, but is it very handful for testing
Related: