Maybe a silly idea, don't know, totally different, but ...
interface MyConfig {
@UseDefaults( value = "user.home", source =
DefaultsSource.SYSTEM_PROPERTIES )
Property<String> homeDirectoryPath();
@UseDefaults( value = "SOME_PORT", source = DefaultsSource.ENVIRONMENT
)
Property<Integer> thePortWeWantToUse();
Property<List<String>> somethingElse();
}
Too much annotations, erk ...
Looking at it this way the goal could be seen as providing default
values per property.
We already have the assembly time initial value provider that can do
just that, or could be enhanced to (couldn't find tests for it ...). We
could then provide some helpers for system properties / environment
variables mapping.
BTW, shouldn't InitialValueProvider be named DefaultValueProvider
instead, for consistency?