eclipse - How to find which data class not overriden toString() method in java project -


in our project data classes (pojo used api request & response) overridding tostring() method provide meaningful information - data classes not overridden tostring().

when application print logs of data class in tostring() not overridden, not printing meaningful information call object class tostring().

so want identify data class , provide tostring() implementation.

is there way identify kind of class in tostring() method not implemented.

looking in every data class , checking tostring() method tedious , time consuming task.

is there better way using tools eclipse or else?

one way use reflections library obtain classes within given package, note not work on classes anonymous, private, partial, inaccessible, ..etc, best way manually per @ghostcat answer

now should go route, here's how done, first obtain classes through reflections library, quoted this answer @staale

reflections reflections = new reflections("my.project.prefix");  set<class<? extends object>> allclasses =             reflections.getsubtypesof(object.class); 

then iterate on classes, , check if tostring declared in class itself

for(class clazz : allclasses) {     if(!clazz.getmethod("tostring").getdeclaringclass().getname().equals(clazz.getname()))         system.out.println("tostring not overridden in class "+clazz.getname()); } 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -