matteobaccan / owner

Get rid of the boilerplate code in properties based configuration.

Home Page:https://matteobaccan.github.io/owner/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Converter / Decryptor is not being called when property value is referenced in another property

mrunalgosar-tripactions opened this issue · comments

Issue Summary: Converter / Decryptor is not being called when property value is referenced in another property.
Description: Suppose a user refers to a key in another key, then we would expect the source key's converted value to be available in target key instead of original value.
Refer sample test below:

local.properties

key1=random
url=${key1}

UnitTest.java

public class UnitTest {

    @Config.Sources({
            "classpath:local.properties",
            "file:src/test/resources/applications.properties"
    })
    public interface ConfigTest extends Config {

        @Key("key1")
        @ConverterClass(Conv.class)
        String key1();

        @Key("url")
        String url();

        class Conv implements Converter<String> {

            @Override
            public String convert(Method method, String s) {
                return s + " value";
            }
        }
    }

    @Test
    void test() {
        ConfigTest test = ConfigCache.getOrCreate(ConfigTest.class);
        System.out.println("key1 property value -> " + test.key1());
        System.out.println("url property value -> " + test.url());
    }
}

Output:

key1 property value -> random value
url property value -> random <!-- Here we would expect 'random value' instead of just random-->