Caso Scala com 22 campos, mas com problema com play-json no scala 2.11.5
Com o Scala 2.11, temos mais de 22 campos em uma classe de caso, certo?
case class SomeResponse(
var compositeKey: String,
var id1: String,
var id2: String,
var firstName: String,
var lastName: String,
var email: String,
var email2: String,
var birth: Long,
var gender: String,
var phone: Phone,
var city: String,
var zip: String,
var carriage: Boolean,
var carriage2: Boolean,
var fooLong: Long,
var fooLong2: Long,
var suspended: Boolean,
var foo: Foo,
var address: String,
var suite: String,
var state: String,
var instructions: String)
implicit val formatSomeResponse = Json.format[SomeResponse]
Bem, o acima é uma classe de caso que tem exatamente 22 campos com o formato play-json, agora quando eu compilar, eu recebo este erro:
SomeFile.scala:126: value apply is not a member of play.api.libs.functional.FunctionalBuilder[play.api.libs.json.OFormat]#CanBuild22[String,String,String,String,String,String,String,Long,String,com.Phone,String,String,Boolean,Boolean,Long,Long,Boolean,com.Foo,String,String,String,String]
E a classe de caso Telefone e Foo, cada um tem dois campos cada.
Então, por que estou enfrentando o problema, ele não ultrapassa o limite de 22 campos ou há algo mais que eu fiz de errado e tentei emscala 2.11.5 / 2.11.1 - play-json 2.3
Atualização: Com base nas respostas de James e Phadej
val someResponseFirstFormat: OFormat[(String, String, String, String, String, String, String, Long, String, Phone, String)] =
((__ \ "compositeKey").format[String] and
(__ \ "id1").format[String] and
(__ \ "id2").format[String] and
(__ \ "firstName").format[String] and
(__ \ "lastName").format[String] and
(__ \ "email").format[String] and
(__ \ "email2").format[String] and
(__ \ "birth").format[Long] and
(__ \ "gender").format[String] and
(__ \ "phone").format[Phone] and
(__ \ "city").format[String]).tupled
val someResponseSecondFormat: OFormat[(String, Boolean, Boolean, Long, Long, Boolean, Foo, String, String, String, String)] =
((__ \ "zip").format[String] and
(__ \ "carriage").format[Boolean] and
(__ \ "carriage2").format[Boolean] and
(__ \ "fooLong").format[Long] and
(__ \ "fooLong2").format[Long] and
(__ \ "suspended").format[Boolean] and
(__ \ "foo").format[Foo] and
(__ \ "address").format[String] and
(__ \ "suite").format[String] and
(__ \ "country").format[String] and
(__ \ "instructions").format[String]).tupled
implicit val formatSome: Format[SomeResponse] = (
someResponseFirstFormat and someResponseSecondFormat
).apply({
case ((compositeKey, id1, id2, firstName, lastName, email, email2, birth, gender, phone, city),
(zip, carriage, carriage2, created, updated, suspended, foo, address, suite, country, instructions)) =>
SomeResponse(compositeKey, id1, id2, firstName, lastName, email, email2, birth, gender, phone, city, zip, carriage, carriage2, created, updated, suspended, location, address, suite, country, instructions)
}, huge => ((huge.compositeKey, huge.id1, huge.id2, huge.firstName, huge.lastName, huge.email, huge.email2, huge.birth, huge.gender, huge.phone, huge.city),
(huge.zip, huge.carriage, huge.carriage2, huge.created, huge.updated, huge.suspended, huge.foo, huge.address, huge.suite, huge.country, huge.instructions)))