Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: support java records in addition to java beans as config objects #769

Open
pjroth opened this issue Jun 8, 2022 · 2 comments
Open

Comments

@pjroth
Copy link

pjroth commented Jun 8, 2022

ConfigBeanFactory.create supports the ability to create a typed object with a single method call which is very nice. I am using java 17 and would like to use a record instead of a java bean to take advantage of the much reduced boilerplate possible when using java records.

My proposal is something along the lines of the following:

record MyConfig(String uri, Integer port);

var map = Map.of(
                "uri", "localhost",
                "port", "1234");
var fullConfig = ConfigFactory.parseMap(map)
var myConfig = ConfigRecordFactory.create(fullConfig, MyConfig.class);

assertThat(myConfig.uri(), equalTo("localhost"));
assertThat(myConfig.port(), equalTo("1234"));

Thanks for this great library!

@laglangyue
Copy link

I alse need this feature.

@mkurz
Copy link

mkurz commented Aug 2, 2022

I think you should provide a pull request if you want to see this happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants