jeudi 15 février 2018

Java Relection Instance checking for different classes

I have method which takes in Class references as arguments something like below:

getConfigModule(Class klass) {
    //logic to check the class types
}

We are calling this method from other classes like below:

    getConfigModule(ClassA.class);
    getConfigModule(ClassB.class);
    getConfigModule(ClassC.class);

I need to write some logic in the method to check whether "klass" is of a particular class type or not. For example to check "klass" is of type ClassA and ClassB.





Aucun commentaire:

Enregistrer un commentaire