Support default methods as default value source for @ConfigurationProperties interfaces
Feature description
I have a property class like
@Getter
@Setter
@Introspected
@ConfigurationProperties("some-path")
public class SomeProperties {
...
private Path tempPath = Path.of(FileUtils.getTempDirectoryPath()).resolve(SUBDIRECTORY);
...
}
with lombok annotations to reduce boilerplate and property tempPath with calculated default value.
I want to refactor it to an interface type, to reduce boilerplate without using lombok
@ConfigurationProperties("some-path")
public interface SomeProperties {
...
Path getTempPath()
...
}
but now i can't build a default value cause @Bindable(defaultValue = ) allows only constants.
I had expected that default methods can solve it
default Path getTempPath() {
return Path.of(FileUtils.getTempDirectoryPath()).resolve(SUBDIRECTORY);
}
but it wouldn't.
It would be nice to implement a feature to allow use default interface method as default property source. :pleading_face:
I ran into this one as well. I agree it would be a nice feature to have.
I take that back. It was actually working just fine for me. I was just misinterpreting what I was seeing.
Can you please confirm that this is still an issue in the latest version of Micronaut?