Overview
MethodReference
and PropertyOrFieldReference
already define local isNullSafe()
methods, but we now need identical methods in Selection
, Projection
, and Indexer
, and we may potentially need null-safe support for additional operators in the future.
However, doing so without a common mechanism will result in an if-block that's required to check each concrete node type separately.
In other words, the current if-block:
https://github.com/spring-projects/spring-framework/blob/b1b9ee0ccf1d6eaaea9c8ba15aec1bc110143e20/spring-expression/src/main/java/org/springframework/expression/spel/ast/CompoundExpression.java#L127-L128
... would grow to something similar to the following:
if ((nextChild instanceof MethodReference methodRef && methodRef.isNullSafe()) ||
(nextChild instanceof PropertyOrFieldReference pofRef && pofRef.isNullSafe()) ||
(nextChild instanceof Selection selection && selection.isNullSafe()) ||
(nextChild instanceof Projection projection && projection.isNullSafe()) ||
(nextChild instanceof Indexer indexer && indexer.isNullSafe())) {
Whereas, something unified like the following would be preferred.
if (nextChild.isNullSafe()) {
Prerequisite For
-
29847
-
32515