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 · 4 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.

@CharNikita
Copy link

As far as I can see, the project is not in active development, however, this feature would be very useful and convenient. Also, I see that the current open pull requests are not accepted. I can take on the implementation of this feature, but I would not like to waste time if the pull request will be rejected in any case.

@havocp You are the most active contributor to the library, can you please comment on whether I can take on the implementation?

@samvel-aivazian
Copy link

We definitely need this feature! Looking forward to seeing updates about it's completion!

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

5 participants