Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sealed abstract class LogRow
- case class TypeARow(x: String, y: Int) extends LogRow
- case class TypeBRow(y: String, z: Double) extends LogRow
- // Here comes the factory
- object LogRow {
- def apply[T <: LogRow : ClassManifest](s: String): T = classManifest[T] match {
- case x: TypeARow => new TypeARow("xpto", 1).asInstanceOf[T]
- case x: TypeBRow => new TypeBRow("xpto", 0.5).asInstanceOf[T]
- }
- }
Add Comment
Please, Sign In to add comment