Release Notes Draft - advantageous/konf GitHub Wiki

Built-in functions for size

You can also specify the sizes with built-in functions if you don't want to use strings.

Using built-in functions to create sizes.

  diskVolumes: [kilobytes(10), megabytes(10), bytes(10), gigabytes(10)]

Loading config files with fallbacks


import static io.advantageous.config.ConfigLoader.*;
...
    private Config config;
    ...
        config = configs(config("test-config.js"), config("reference.js"));

You can load config. The config method is an alias for load(resources...). The configs(config...) creates a series of configs where the configs are search from left to right. The first config that has the object (starting from the left or 0 index) will return the object.

Give the following two configs (from the above example).

test-config.js

var config = {
  abc : "abc",

reference.js

var config = {
  abc : "abcFallback",
  def : "def"
}

You could run this test.

Testing the reference.js is a fallback for test-config.js.


        final String value = config.getString("abc");
        assertEquals("abc", value);

        final String value1 = config.getString("def");
        assertEquals("def", value1);

You can load your config anyway you like. The String abc is found when looking up the key abc because it is in the test-config.js which gets read before the value abcFallback which is in reference.js. Yet the def key yields the "def" because it is defined in reference.js but not test-config.js. You can implement the same style config reading and fallback as is in Type Safe Config but with your DSL.

Combining TypeSafe Config with Konf

https://github.com/advantageous/konf-typesafe-config