-
Notifications
You must be signed in to change notification settings - Fork 1
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
Optionals let you leave out keys #28
Comments
Ye but how the config gonna look if its not there |
don't think yaml would accept |
What do you mean how would the config look if it were not there, there would simply not be a key entry. |
Oh i got it, i think this should be added it would allow more abilities to do with the library |
Not sure if this is supported but i'd pay/donate/support to have this implemented by either the repo maintainer or by someone else |
I dont think that this suggestion respects one of the main ideas of library - no nullability. |
@m4nyA raised a good point. I've always avoided null values because the concept of null is ambiguous. It's usually a bad idea to instruct users to leave a configuration option 'blank'. An empty string and a null value would be treated differently, but from the perspective of a user who knows nothing of Java, this would be quite the surprise. Instead, I recommend using a configuration section which contains an "enable" boolean option: some:
otherKey:
enabled: true
value: 'hello' If you really needed Optional in your code, you could then use a default method which returns an Optional: default Optional<String> optValue() {
return enable() ? Optional.of(value()) : Optional.empty();
} |
Title: If you have an Optional annotated as a config value, not including a key for the value will simply make the Optional return empty.
A configuration with
should load lol() as an empty opt
The text was updated successfully, but these errors were encountered: