|
|
|
|
@ -33,12 +33,15 @@ import org.springframework.util.ObjectUtils;
@@ -33,12 +33,15 @@ import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 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)}" returns "[n, y, n, y, n, y, n, y, n, y]" |
|
|
|
|
* input sequence, returning a new sequence of the same size. |
|
|
|
|
* |
|
|
|
|
* <p>For example: <code>{1,2,3,4,5,6,7,8,9,10}.![#isEven(#this)]</code> evaluates |
|
|
|
|
* to {@code [n, y, n, y, n, y, n, y, n, y]}. |
|
|
|
|
* |
|
|
|
|
* @author Andy Clement |
|
|
|
|
* @author Mark Fisher |
|
|
|
|
* @author Juergen Hoeller |
|
|
|
|
* @author Sam Brannen |
|
|
|
|
* @since 3.0 |
|
|
|
|
*/ |
|
|
|
|
public class Projection extends SpelNodeImpl { |
|
|
|
|
@ -64,9 +67,9 @@ public class Projection extends SpelNodeImpl {
@@ -64,9 +67,9 @@ public class Projection extends SpelNodeImpl {
|
|
|
|
|
|
|
|
|
|
// When the input is a map, we push a special context object on the stack
|
|
|
|
|
// before calling the specified operation. This special context object
|
|
|
|
|
// has two fields 'key' and 'value' that refer to the map entries key
|
|
|
|
|
// and value, and they can be referenced in the operation
|
|
|
|
|
// eg. {'a':'y','b':'n'}.![value=='y'?key:null]" == ['a', null]
|
|
|
|
|
// has two fields 'key' and 'value' that refer to the map entry's key
|
|
|
|
|
// and value, and they can be referenced in the operation -- for example,
|
|
|
|
|
// {'a':'y', 'b':'n'}.![value == 'y' ? key : null] evaluates to ['a', null].
|
|
|
|
|
if (operand instanceof Map<?, ?> mapData) { |
|
|
|
|
List<Object> result = new ArrayList<>(); |
|
|
|
|
for (Map.Entry<?, ?> entry : mapData.entrySet()) { |
|
|
|
|
|