Skip to content

Commit eefdee7

Browse files
committed
Fix syntax in Selection/Projection examples
1 parent ab48ac3 commit eefdee7

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

Diff for: spring-expression/src/main/java/org/springframework/expression/spel/ast/Projection.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@
3333

3434
/**
3535
* Represents projection, where a given operation is performed on all elements in some
36-
* input sequence, returning a new sequence of the same size. For example:
37-
* "{1,2,3,4,5,6,7,8,9,10}.!{#isEven(#this)}" returns "[n, y, n, y, n, y, n, y, n, y]"
36+
* input sequence, returning a new sequence of the same size.
37+
*
38+
* <p>For example: <code>{1,2,3,4,5,6,7,8,9,10}.![#isEven(#this)]</code> evaluates
39+
* to {@code [n, y, n, y, n, y, n, y, n, y]}.
3840
*
3941
* @author Andy Clement
4042
* @author Mark Fisher
4143
* @author Juergen Hoeller
44+
* @author Sam Brannen
4245
* @since 3.0
4346
*/
4447
public class Projection extends SpelNodeImpl {
@@ -64,9 +67,9 @@ protected ValueRef getValueRef(ExpressionState state) throws EvaluationException
6467

6568
// When the input is a map, we push a special context object on the stack
6669
// before calling the specified operation. This special context object
67-
// has two fields 'key' and 'value' that refer to the map entries key
68-
// and value, and they can be referenced in the operation
69-
// eg. {'a':'y','b':'n'}.![value=='y'?key:null]" == ['a', null]
70+
// has two fields 'key' and 'value' that refer to the map entry's key
71+
// and value, and they can be referenced in the operation -- for example,
72+
// {'a':'y', 'b':'n'}.![value == 'y' ? key : null] evaluates to ['a', null].
7073
if (operand instanceof Map<?, ?> mapData) {
7174
List<Object> result = new ArrayList<>();
7275
for (Map.Entry<?, ?> entry : mapData.entrySet()) {

Diff for: spring-expression/src/main/java/org/springframework/expression/spel/ast/Selection.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
/**
3838
* Represents selection over a map or collection.
3939
*
40-
* <p>For example, <code>{1,2,3,4,5,6,7,8,9,10}.?{#isEven(#this)}</code> evaluates
40+
* <p>For example, <code>{1,2,3,4,5,6,7,8,9,10}.?[#isEven(#this)]</code> evaluates
4141
* to {@code [2, 4, 6, 8, 10]}.
4242
*
43-
* <p>Basically a subset of the input data is returned based on the
44-
* evaluation of the expression supplied as selection criteria.
43+
* <p>Basically a subset of the input data is returned based on the evaluation of
44+
* the expression supplied as selection criteria.
4545
*
4646
* @author Andy Clement
4747
* @author Mark Fisher

0 commit comments

Comments
 (0)