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

后端 未结 2 719
被撕碎了的回忆
被撕碎了的回忆 2020-12-15 11:09

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 ar

2条回答
  •  心在旅途
    2020-12-15 12:13

    ClassUtil now contains this functionality (v1.4.0, maybe also in earlier versions):

    val finder = ClassFinder()
    val impl = ClassFinder.concreteSubclasses("foo.NamedEntity", finder.getClasses())
    

提交回复
热议问题