objectcomputing / check-ins

Other
7 stars 7 forks source link

Remove instance booleans and fix conditionals #2506

Closed timyates closed 1 week ago

timyates commented 1 week ago

Where possible this commit switches from Boolean class parameters to primitive booleans.

The problem with Boolean is that it introduces 3 states, TRUE, FALSE and null.

Where the contract has a Nullable requirement, I have updated the if statements, as if (obj.nullableMember()) { will throw a null pointer exception if the Boolean result is null. The safe replacement is if (Boolean.TRUE.equals(obj.nullableMember())) {

timyates commented 1 week ago

Unexpected NullPointerExceptions are worse imho 😉