i want to create case class dynamically and for that i wrote program but not able to define case class as program return String type instead of defining class.
eg. case class + " " + $class_name " (" + $col_list + ")"
expected: defined class abc
i want to create case class dynamically and for that i wrote program but not able to define case class as program return String type instead of defining class.
eg. case class + " " + $class_name " (" + $col_list + ")"
expected: defined class abc
Warning: you need to be 100% sure that the code you are generating compiles.
You can do this:
val yourPath = ...\\somePath.scala
new PrintWriter(yourPath) {
write(s"case class $class_name($col_list)")
close()
}
This way you create a scala class parsing Strings. If the class generates wrong it wont compile, so you need to be sure what you are generating.