I have a large package of models which I'd like cleaning up. So basically, a model looks like;
case class ExampleModel(…) extends Model {
…
}
object ExampleModel {
def find = new Finder[Long, ExampleModel](classOf[Long], classOf[ExampleModel]) // very repetitive
…
}
Now, I've been trying to define an abstract class
that provides me a companion object specific find
method;
abstract class Findable[T: ClassTag] {
self: T => def find = new Finder[Long, T](classOf[Long], classOf[T])
}
But compilation fails with:
class type required but T found
What is the correct way to approach this?