forked from ceedubs/ficus
-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
When having both foo-bar
and foo
present in a case class, Ficus attempts to parse the value of foo-bar
and assign it to foo
. When they both have different types this results in a ClassCastException, however when the types are the same, ficus will assign the value of foo-bar
to both foo
and foo-bar
.
Example that fails with ClassCastException.
import net.ceedubs.ficus.Ficus._
import net.ceedubs.ficus.readers.ArbitraryTypeReader._
import com.typesafe.config._
case class TestSettings(val `foo-bar`: Long, `foo`: String)
val config = ConfigFactory.parseString("""{ foo-bar: 3, foo: "4" }""")
val settings = config.as[TestSettings] // throws java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String!
Example that doesn't fail, but assigns the value of foo-bar
to foo
.
case class TestSettings2(val `foo-bar`: String, `foo`: String)
val config = ConfigFactory.parseString("""{ foo-bar: "foo-bar", foo: "foo" }""")
val settings = config.as[TestSettings2]
println(settings.`foo-bar`) // prints out foo-bar
println(settings.foo) // also prints out foo-bar!
Metadata
Metadata
Assignees
Labels
No labels