Description
Hello Nicolai,
I just noticed some inconsistencies with handling null-values in Nestings.
If you create a nesting, and the outer property ('currentEmployeeProperty' in your example) contains 'null', a NullPointerExcepton is thrown.
However if the nesting was already created (using a non-null Employee) and the currentEmployeeProperty's value is set to 'null' at a later time, no exception is thrown.Additionally, the NestedProperty is not updated and keeps its old value. I have created a simple test showing the behaviour.
I know that 'null' in the outer property (Employee) is ambigous. What should happen if there is a Nesting on, for example Employee::nameProperty, the Employee is null, and the Name is changed? Either a Exception could be thrown (there is no Employee whose name can be set), or a new Employee could be created, and the name set.
I would personally really like it if Nestings could handle both described alternatives.
- If the outer properties value becomes 'null', the inner property should become null, too (not keep its last value, as it is currently).
- Throwing a NullPointerException could be the default way of handling 'null' in outer properties when writing to inner-properties.
- As an alternative one could specifiy an optional Supplier, which creates a new value for the outer property.