When defining a generic class in Scala how can I ensure that the type parameter 'A' must be a case class?
class TypedCollection[A](name: String){}
Context:
I'm trying to define a generic 'TypedCollection' wrapper class to interact a reactivemongo JSONCollection as though it were a collection of case classes (similar to Typesafe Slick for relational databases).
The reason 'A' must be a case class is so it will automatically be given an 'unapply' method. This method is used in the generic class when creating the implicit conversions for type 'A' to a JsObject or BSONObject so it can be stored in MongoDB. i.e.
implicit val AWrites = Json.writes[A]
implicit val AReads = Json.reads[A]