[PartialTransformer] Field Option[Field].None to Proto3.Fields.Default #474
-
|
Hello, Domain case class Proto3 PartialTransformers: mappingResult.right is None I am wondering is there any way to map missed | Option values with default values. Could you help me with that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
With the information code I cannot reproduce anything as I am missing types ( From the description, an I can only guess that you wanted to use default values although default values are used when there is no source field, not when the source field is implicit val noneIntIsZero: Transformer[Option[Int], Int] = _.getOrElse(0)
implicit val noneLongIsZero: Transformer[Option[Long], Long] = _.getOrElse(0L)
implicit val noneStringIsEmpty: Transformer[Option[String], String] = _.getOrElse("")
clientProductEntity.into[ClientProduct]....transformwould handle most cases. I don't see how |
Beta Was this translation helpful? Give feedback.
With the information code I cannot reproduce anything as I am missing types (
Seq[Map],com.pricespider.unity.domain.ClientProduct.Promo), fields (ClientProductEntityhas noPSCBID,PSCID) and in general this code doesn't compile (Option[Seq(Promo)]instead ofOption[Seq[Promo]]). So I can only guess, what you want to achieve.From the description, an I can only guess that you wanted to use default values although default values are used when there is no source field, not when the source field is
None. There is no support for using default values asNonehandling, however for this particular case: