mercredi 30 décembre 2015

Get all the classes that implments a trait in Scala using reflection

I want to list out all the case classes which implements a particular trait. I am currently using Clapper ClassUtil for doing that. I am able to get the case classes that are directly implementing a trait. However, I am not able to get the other classes which are not directly implementing the trait. How can I get all classes which directly or indirectly implements a trait. ?

val finder = ClassFinder()
finder.getClasses().filter(_.isConcrete).filter(_.implements("com.myapp.MyTrait"))

Scala Version : 2.11

Clapper Class Util Version : 1.0.6

Is there any other way I can get these information? Can someone point me to the right direction? I tried using scala.reflect but could not understand how to get the info.





Aucun commentaire:

Enregistrer un commentaire