5

I am trying to list all the class in a package in compile time.

Let's define a project with the following structure:

com.main
   Main.scala
com.package
   Method.scala
com.package.method1
   Method1.scala
com.package.method2
    Method2.scala

Where:

Method.scala

abstract class Method(val name: String) {
}

Method1.scala and Method2.scala (Changing the respective names)

class Method1 extends Method(name = "Method1") {
}

I want to obtain a list of classes defined in com.package._ from Main.scala as:

object Main() {
    val names = List("Method1", "Method2")
}

I could hardcode the name (as it was shown) but I was wondering if it is possible to obtain theses names in compile time. I know that in runtime could use http://software.clapper.org/classutil/

ie8888
  • 171
  • 1
  • 10

0 Answers0