Now I'm migrating legacy Java project to Scala.
I faced the following problem: I call remote service that returns java.util.List<SomePojo>
. SomePojo
class contains about 50 fields and I'm interested what are the best practices to pass it to UI in JSON format.
I'm using scalatra framework and it is just fine, but how to put this POJO to case class while case classes are limited with 21 fields? Or is there better way?
This was fixed in Scala 2.11.
If you can't use 2.11, split up the fields into separate case classes, and then combine those in an aggregate one.
case class Part1(a: Int, b: Int, c: Int)
case class Part2(d: Int, e: Int, f: Int)
case class Aggregate(part1: Part1, part2: Part2)
val aggregate = Aggregate(Part1(0, 1, 2), Part2(3, 4, 5))
aggregate match {
case Aggregate(Part1(a, b, c), Part2(d, e, f)) =>
}