Tries to convert the configuration to a type for which exists an instance of ConcreteValue in scope.
Tries to convert the configuration to a type for which exists an instance of
ConcreteValue in scope. Since the configuration is represented as a AbstractMap, A
is generally a final case class or,
simply, AbstractMap. The conversion to a case class happens automatically, you don't need to implement a
ConcreteValue instance for it. The only requirement is that the configuration keys and values match the case
class's field names and values, respectively. For example, given a config object pointing to this configuration:
{ bar: 42, baz: "hello" }
and this final case class:
final case class Foo(bar: Int, baz: String)
the conversion is possible as in:
config.as[Foo] // result Success(Foo(42, "hello"))
a Try[A]
, which is a Success
if the conversion is successful, a Failure
if it's not.
Tries to retrieve a config value and convert it into a concrete Scala value.
Tries to retrieve a config value and convert it into a concrete Scala value. It may fail in one of two ways:
1. The key looked for is not found.
2. The conversion is not doable.
the key to look for
Merges two Config objects.
Merges two Config objects. Basically if you look at the configuration as Map
s, the resulting Config object
is like using ++
with the two underlying Map
s, as in thisConfig ++ thatConfig. E.g.:
conf1
:
{ foo = { alpha = 1, bar = "hello" }, baz = 42 }
conf2
:
{ foo = { baz = 15, bar = "goodbye" }, baz = 1, zoo = "hi" }
conf1.merge(conf2)
:
{ foo = { baz = 15, bar = "goodbye" }, baz = 1, zoo = "hi" }
Merges two Config objects.
Merges two Config objects. Given a key, if the correspondent value is a map then thatConfig
's value is
"recursively" merged to this config's value otherwise thatConfig
's value replaces this config's value. E.g.:
conf1
:
{ foo = { alpha = 1, bar = "hello" }, baz = 42 }
conf2
:
{ foo = { baz = 15, bar = "goodbye" }, baz = 1, zoo = "hi" }
conf1.recursivelyMerge(conf2)
:
{ foo = { alpha = 1, baz = 15, bar = "goodbye" }, baz = 1, zoo = "hi" }
This class represents the configuration.
2015-11-27