Skip to content

Transform wrapped class #441

Answered by MateuszKubuszok
jeengbe asked this question in Q&A
Discussion options

You must be logged in to vote

Currently the only way to combine values from 2 levels of nesting is:

  • to select one of them as the main source of values
  • connect values from the other level of nesting manually
//> using dep io.scalaland::chimney::0.8.3
import io.scalaland.chimney.dsl.*

case class A(a: String)
case class WithB[X](b: String, x: X)
case class C(a: String, b: String) // I modified this for this example, see below

// WithB[A] as the "main" object
WithB("b", A("a")).into[C].withFieldComputed(_.a, _.x.a).transform
// or A as the "main" object
val withB = WithB("b", A("a")) 
withB.x.into[C].withFieldConst(_.b, withB.b).transform

Handling it magically OOTB is not in the scope ever (since the compilation time …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@jeengbe
Comment options

@jeengbe
Comment options

@MateuszKubuszok
Comment options

Answer selected by jeengbe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants