Previous answer was because i didn't understood your question right. This should answer your question:
If you want this only for debugging purposes you can use it like that:
trait A{
def myMethod(employee:Emp):Unit
}
case class Emp(id:String,name:String) extends A {
override def myMethod(employee: Emp): Unit =
this.productIterator.toList.foreach(println)
}
Emp("1", "2").myMethod(None.orNull)
But more logical would be to use object with this nonGeneric method:
case class Emp(id:String,name:String)
object A{
def myMethod(employee: Emp):Unit = {
employee.productIterator.toList.foreach(println)
}
}
A.myMethod(Emp("1", "2"))
For logging purposes you can use just apache log4j
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…