So I have a class A
and there are multiple classes that extend from class A. I create an instance of this class, is there a way to get all the other classes that extend A?
Something like:
A a = new A();
a.getAllSubclasses();
Only way I tought of doing this is scanning the entire project for all the classes and storing them in a list and then checking manuall if each class extends from A with instanceOf.
List<Class> classList;
classList.each{
if(it instanceOf a)
//do stuff
}
This seems bad especially for a huge project with hundred of classes.
Aucun commentaire:
Enregistrer un commentaire