Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sealed abstract class LogRow
- case class SemasioRow(x: String, y: Int) extends LogRow
- case class TectonicRow(y: String, z: Float) extends LogRow
- // Here comes the factory
- object LogRow {
- def apply[T](s: String)(implicit m: Manifest[T]) = m match {
- case x: Manifest[SemasioRow] => new SemasioRow("xpto", 1) // It's technically possible to make this a call to a companion SemasioRow object that decodes a string
- case x: Manifest[TectonicRow] => new TectonicRow("xpto", 2)
- }
- }
- object LogReader{
- def apply(filename: String): List[LogRow] = {
- List(LogRow[SemasioRow]("hello"))
- }
- }
Add Comment
Please, Sign In to add comment