Say I get a class instance with:
Class clazz = Class.forName("SomeClass");
And I have the following class structure:
interface SuperClass {}
class SomeClass implements SuperClass {}
How can I see whether my clazz object is a subclass of SuperClass.class?
Basically, here's what I want to achieve:
I have an interface of some type, and then various implementations of that interface. However, which implementation will be used for future processes in my application is a choice I'd like the user to make, so for now I have the very simplistic approach of forcing the user to type the implementation class name in a terminal. I then obviously need to check whether what he typed in actually is a class, and if it is, if it is an implementation of my interface. What do you think would be the best way to go about this?
Aucun commentaire:
Enregistrer un commentaire