Skip to content

Commit 81cdfaf

Browse files
committed
Polishing
1 parent d5cb1d9 commit 81cdfaf

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

spring-expression/src/main/java/org/springframework/expression/TypedValue.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,8 @@
2222

2323
/**
2424
* Encapsulates an object and a {@link TypeDescriptor} that describes it.
25-
* The type descriptor can contain generic declarations that would not
25+
*
26+
* <p>The type descriptor can contain generic declarations that would not
2627
* be accessible through a simple {@code getClass()} call on the object.
2728
*
2829
* @author Andy Clement

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,9 @@
3636

3737
/**
3838
* Represents selection over a map or collection.
39-
* For example: {1,2,3,4,5,6,7,8,9,10}.?{#isEven(#this) == 'y'} returns [2, 4, 6, 8, 10]
39+
*
40+
* <p>For example, <code>{1,2,3,4,5,6,7,8,9,10}.?{#isEven(#this)}</code> evaluates
41+
* to {@code [2, 4, 6, 8, 10]}.
4042
*
4143
* <p>Basically a subset of the input data is returned based on the
4244
* evaluation of the expression supplied as selection criteria.
@@ -100,11 +102,10 @@ protected ValueRef getValueRef(ExpressionState state) throws EvaluationException
100102
Object val = selectionCriteria.getValueInternal(state).getValue();
101103
if (val instanceof Boolean b) {
102104
if (b) {
105+
result.put(entry.getKey(), entry.getValue());
103106
if (this.variant == FIRST) {
104-
result.put(entry.getKey(), entry.getValue());
105107
return new ValueRef.TypedValueHolderValueRef(new TypedValue(result), this);
106108
}
107-
result.put(entry.getKey(), entry.getValue());
108109
lastKey = entry.getKey();
109110
}
110111
}
@@ -120,22 +121,22 @@ protected ValueRef getValueRef(ExpressionState state) throws EvaluationException
120121
}
121122

122123
if ((this.variant == FIRST || this.variant == LAST) && result.isEmpty()) {
123-
return new ValueRef.TypedValueHolderValueRef(new TypedValue(null), this);
124+
return new ValueRef.TypedValueHolderValueRef(TypedValue.NULL, this);
124125
}
125126

126127
if (this.variant == LAST) {
127128
Map<Object, Object> resultMap = new HashMap<>();
128129
Object lastValue = result.get(lastKey);
129-
resultMap.put(lastKey,lastValue);
130-
return new ValueRef.TypedValueHolderValueRef(new TypedValue(resultMap),this);
130+
resultMap.put(lastKey, lastValue);
131+
return new ValueRef.TypedValueHolderValueRef(new TypedValue(resultMap), this);
131132
}
132133

133-
return new ValueRef.TypedValueHolderValueRef(new TypedValue(result),this);
134+
return new ValueRef.TypedValueHolderValueRef(new TypedValue(result), this);
134135
}
135136

136137
if (operand instanceof Iterable || ObjectUtils.isArray(operand)) {
137-
Iterable<?> data = (operand instanceof Iterable<?> iterable ?
138-
iterable : Arrays.asList(ObjectUtils.toObjectArray(operand)));
138+
Iterable<?> data = (operand instanceof Iterable<?> iterable ? iterable :
139+
Arrays.asList(ObjectUtils.toObjectArray(operand)));
139140

140141
List<Object> result = new ArrayList<>();
141142
int index = 0;

0 commit comments

Comments
 (0)