-
Notifications
You must be signed in to change notification settings - Fork 132
Config instance builder #1021
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
base: main
Are you sure you want to change the base?
Config instance builder #1021
Conversation
radcortez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
|
I've now started to look into this and pushed some initial implementation that includes:
Of course, there is still a lot missing, and even the pieces I did are only for the most basic cases, so I need to start looking into all the edge cases, but it is a start. In terms of the API, I think we could start with something smaller and drop On another note, interface Server {
String host();
int port();
}
Server server = forInterface(Server.class)
.with(Server::host, "localhost")
.with(Server::port, 8080)
.build();So, |
This is caused by using a type variable in the first argument, which I believe prevents inferencing due to some complexity aspect. I recommend creating a custom interface type for each type of property which also implements |
|
@dmlloyd I think this is ready for a first version:
I've removed the Let me know what you think. |
|
Seems OK. Don't forget to JavaDoc the rest of the API. |
- Builder class generation - Simple leaf types and primitives - Simple optionals - @WithDefault
- Builder class generation - Leaf types and primitives - Optionals - Maps - Collections - @WithDefault
- Optional Group - Map with Collections - Default methods
- Remove unused methods from ConfigInstanceBuilder - Share the same code between ConfigInstanceBuilder and ConfigMappingContext - Simplify ConfigMappingGenerator
Update: there is now a basic (but incomplete) implementation.
This is a first draft of the builder API for constructing configuration instances. No implementation is included yet; this is just for API review.
Fixes #1001.