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

Support of Optional for data binding [SPR-13933] #18505

Closed
spring-projects-issues opened this issue Feb 9, 2016 · 1 comment
Closed

Support of Optional for data binding [SPR-13933] #18505

spring-projects-issues opened this issue Feb 9, 2016 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Feb 9, 2016

Stéphane Nicoll opened SPR-13933 and commented

See spring-projects/spring-boot#5110


Issue Links:

Referenced from: commits 700ab2f

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

For the purposes of that Boot ticket, our arrangement actually works as designed: As long as a ConversionService is associated with the binder, we do wrap a given value as an Optional: either for an actual value, or as Optional.empty for a given null value.

Note that the binder does not actually set anything for unspecified properties. It strictly reacts to specified property values only. So if Optional.empty is desired for non-specified properties, the caller would have to manually add a null value for each affected property.

All in all, I would simply initialize those fields with Optional.empty(), not least of it all for the invariants of that class itself.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants