You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of now you would need to write your own custom ValueReader[AbClass] which looks at the field name and determine which sub-class is in the config and use the appropriate ValueReader for that subclass to read the value. The ValueReader for subclasses can be automatically generated by import net.ceedubs.ficus.readers.ArbitraryTypeReader._ and then implicitly[ValueReader[C1Class]] .
We would also love to see efforts to enhance the current macro to handle coproduct.
Hi,
How would you approach an abstract reader?
eg:
abstract class AbClass
case class C1Class(x1: Int, x2:String) extends AbClass
case class C2Class(x3: String) extends AbClass
Then have a config which looks like
{
"C2Class": {
"x1": "foo"
}
}
and let config.as[AbClass] do its job inferring the type. Without having to list all possible case classes as None options by default
Thanks,
Saif
The text was updated successfully, but these errors were encountered: