Skip to content

Commit 1e4275a

Browse files
committed
Implement optional get<list>() methods in EvaluationContext as default methods
1 parent 33fbd71 commit 1e4275a

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,18 @@ public interface EvaluationContext {
4747

4848
/**
4949
* Return the default root context object against which unqualified
50-
* properties/methods/etc should be resolved. This can be overridden
51-
* when evaluating an expression.
50+
* properties, methods, etc. should be resolved.
51+
* <p>This can be overridden when evaluating an expression.
5252
*/
5353
TypedValue getRootObject();
5454

5555
/**
5656
* Return a list of accessors that will be asked in turn to read/write a property.
57+
* <p>The default implementation returns an empty list.
5758
*/
58-
List<PropertyAccessor> getPropertyAccessors();
59+
default List<PropertyAccessor> getPropertyAccessors() {
60+
return Collections.emptyList();
61+
}
5962

6063
/**
6164
* Return a list of index accessors that will be asked in turn to access or
@@ -69,13 +72,19 @@ default List<IndexAccessor> getIndexAccessors() {
6972

7073
/**
7174
* Return a list of resolvers that will be asked in turn to locate a constructor.
75+
* <p>The default implementation returns an empty list.
7276
*/
73-
List<ConstructorResolver> getConstructorResolvers();
77+
default List<ConstructorResolver> getConstructorResolvers() {
78+
return Collections.emptyList();
79+
}
7480

7581
/**
7682
* Return a list of resolvers that will be asked in turn to locate a method.
83+
* <p>The default implementation returns an empty list.
7784
*/
78-
List<MethodResolver> getMethodResolvers();
85+
default List<MethodResolver> getMethodResolvers() {
86+
return Collections.emptyList();
87+
}
7988

8089
/**
8190
* Return a bean resolver that can look up beans by name.

spring-expression/src/main/java/org/springframework/expression/spel/support/SimpleEvaluationContext.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.springframework.core.convert.ConversionService;
2727
import org.springframework.core.convert.TypeDescriptor;
2828
import org.springframework.expression.BeanResolver;
29-
import org.springframework.expression.ConstructorResolver;
3029
import org.springframework.expression.EvaluationContext;
3130
import org.springframework.expression.MethodResolver;
3231
import org.springframework.expression.OperatorOverloader;
@@ -146,15 +145,6 @@ public List<PropertyAccessor> getPropertyAccessors() {
146145
return this.propertyAccessors;
147146
}
148147

149-
/**
150-
* Return an empty list, always, since this context does not support the
151-
* use of type references.
152-
*/
153-
@Override
154-
public List<ConstructorResolver> getConstructorResolvers() {
155-
return Collections.emptyList();
156-
}
157-
158148
/**
159149
* Return the specified {@link MethodResolver} delegates, if any.
160150
* @see Builder#withMethodResolvers

0 commit comments

Comments
 (0)