It's a little bit more than adding a built-in conversion:
- For
Optional<T> prop source property:
- add check for
prop.isPresent() in addition to the null-check (in every spot where we currently use our null-check assignment wrapper)
- using
prop.get() to fetch the value
- For
Optional<T> prop target property:
- use
Optional.empty() instead of null for null-assignments, or Optional.ofNullable(..) for other assignments.
Optionally (pun intended) also support the equivalent in Guavas com.google.common.base.Optional, which uses different names for the factory methods.
It's a little bit more than adding a built-in conversion:
Optional<T> propsource property:prop.isPresent()in addition to the null-check (in every spot where we currently use our null-check assignment wrapper)prop.get()to fetch the valueOptional<T> proptarget property:Optional.empty()instead ofnullfor null-assignments, orOptional.ofNullable(..)for other assignments.Optionally (pun intended) also support the equivalent in Guavas
com.google.common.base.Optional, which uses different names for the factory methods.