On Tue, 11 Jan 2022 13:04:52 GMT, Marius Hanl <mh...@openjdk.org> wrote:

> When a null value is possible, guards against are needed. Unfortunately there 
> is no built-in way to forbid null in Java as whole.

I think null checks should only be done to verify the preconditions of an 
operation, and not to guard against bugs. This means that, when `null` is not a 
_valid_ value for a property (regardless of whether it is a _possible_ value), 
no attempt should be made to guard against this in downstream code. In fact, I 
would argue that doing so is a strong code smell.

The question is whether or not `null` should be a valid value for the 
`selectionModel` and `focusModel` properties. I think there are good reasons to 
think that it shouldn't. The primitive property classes (`IntegerProperty`, 
`BooleanProperty`, etc.) have the same issue, and they deal with this situation 
by coercing the invalid `null` value to their respective default value.

It's not clear to me whether the `ListCellBehavior.anchor` attached property 
setter would need any special-casing. When `null` (or `-1` in case of 
`ListViewBehavior.setAnchor`) is passed in, it seems to remove the anchor. 
Isn't that what we'd expect?

-------------

PR: https://git.openjdk.java.net/jfx/pull/711

Reply via email to