Retain null-safe syntax in AST representation of SpEL indexers
Prior to this commit, SpEL's CompoundExpression omitted the null-safe syntax in AST string representations of indexing operations. To address this, this commit implements isNullSafe() in Indexer. See gh-29847
This commit is contained in:
parent
4d433174eb
commit
d2bd0d5716
|
@ -127,6 +127,15 @@ public class Indexer extends SpelNodeImpl {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Does this node represent a null-safe index operation?
|
||||
* @since 6.2
|
||||
*/
|
||||
@Override
|
||||
public final boolean isNullSafe() {
|
||||
return this.nullSafe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
|
||||
return getValueRef(state).getValue();
|
||||
|
|
|
@ -60,8 +60,8 @@ class ParsingTests {
|
|||
parseCheck("property1?.property2?.methodOne()");
|
||||
parseCheck("property1?.methodOne('enigma')?.methodTwo(42)");
|
||||
parseCheck("property1?.methodOne()?.property2?.methodTwo()");
|
||||
parseCheck("property1[0]?.property2['key']?.methodTwo()");
|
||||
parseCheck("property1[0][1]?.property2['key'][42]?.methodTwo()");
|
||||
parseCheck("property1?.[0]?.property2?.['key']?.methodTwo()");
|
||||
parseCheck("property1?.[0]?.[1]?.property2?.['key']?.[42]?.methodTwo()");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue