Class Projection

java.lang.Object
org.springframework.expression.spel.ast.SpelNodeImpl
org.springframework.expression.spel.ast.Projection
All Implemented Interfaces:
Opcodes, SpelNode

public class Projection extends SpelNodeImpl
Represents projection, where a given operation is performed on all elements in some input sequence, returning a new sequence of the same size.

For example: {1,2,3,4,5,6,7,8,9,10}.![#isEven(#this)] evaluates to [n, y, n, y, n, y, n, y, n, y].

Null-safe Projection

Null-safe projection is supported via the '?.!' operator. For example, 'names?.![#this.length]' will evaluate to null if names is null and will otherwise evaluate to a sequence containing the lengths of the names. As of Spring Framework 7.0, null-safe projection also applies when performing projection on an Optional target. For example, if names is of type Optional<List<String>>, the expression 'names?.![#this.length]' will evaluate to null if names is null or empty and will otherwise evaluate to a sequence containing the lengths of the names, effectively names.get().stream().map(String::length).toList().

Since:
3.0
Author:
Andy Clement, Mark Fisher, Juergen Hoeller, Sam Brannen