lundi 20 avril 2015

Finding all classes with specific type

Let's assume following setup:

trait Fruit{
def name:String
}

trait Fruit2 extends Fruit{
def name:String
}

case class Apple(name:String) extends Fruit
case class Pear(name:String) extends Fruit
case class Dragon-fruit(name:String) extends Fruit2

trait Color
case class ColoredApple[C](name String) extends Fruit

case class Red extends Color
val RedApple = ColoredApple[Red]("red apple")
val ...

First, is there any way instead of reflection to get all Fruit classes? How can I get a list of these classes and variables (e.g. all ColoredApple with Red color) using/not-using reflections?

Aucun commentaire:

Enregistrer un commentaire