Skip to content

Commit baa698e

Browse files
committed
Polishing
Issue: SPR-9495
1 parent b7ff26a commit baa698e

File tree

4 files changed

+39
-44
lines changed

4 files changed

+39
-44
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,51 +33,51 @@
3333
public interface EvaluationContext {
3434

3535
/**
36-
* @return the default root context object against which unqualified
37-
* properties/methods/etc should be resolved. This can be overridden when
38-
* evaluating an expression.
36+
* Return the default root context object against which unqualified
37+
* properties/methods/etc should be resolved. This can be overridden
38+
* when evaluating an expression.
3939
*/
4040
TypedValue getRootObject();
4141

4242
/**
43-
* @return a list of resolvers that will be asked in turn to locate a constructor
43+
* Return a list of resolvers that will be asked in turn to locate a constructor.
4444
*/
4545
List<ConstructorResolver> getConstructorResolvers();
4646

4747
/**
48-
* @return a list of resolvers that will be asked in turn to locate a method
48+
* Return a list of resolvers that will be asked in turn to locate a method.
4949
*/
5050
List<MethodResolver> getMethodResolvers();
5151

5252
/**
53-
* @return a list of accessors that will be asked in turn to read/write a property
53+
* Return a list of accessors that will be asked in turn to read/write a property.
5454
*/
5555
List<PropertyAccessor> getPropertyAccessors();
5656

5757
/**
58-
* @return a type locator that can be used to find types, either by short or fully
59-
* qualified name.
58+
* Return a type locator that can be used to find types, either by short or
59+
* fully qualified name.
6060
*/
6161
TypeLocator getTypeLocator();
6262

6363
/**
64-
* @return a type converter that can convert (or coerce) a value from one type to another.
64+
* Return a type converter that can convert (or coerce) a value from one type to another.
6565
*/
6666
TypeConverter getTypeConverter();
6767

6868
/**
69-
* @return a type comparator for comparing pairs of objects for equality.
69+
* Return a type comparator for comparing pairs of objects for equality.
7070
*/
7171
TypeComparator getTypeComparator();
7272

7373
/**
74-
* @return an operator overloader that may support mathematical operations
75-
* between more than the standard set of types
74+
* Return an operator overloader that may support mathematical operations
75+
* between more than the standard set of types.
7676
*/
7777
OperatorOverloader getOperatorOverloader();
7878

7979
/**
80-
* @return a bean resolver that can look up beans by name
80+
* Return a bean resolver that can look up beans by name.
8181
*/
8282
BeanResolver getBeanResolver();
8383

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,26 @@
2121
* repeat an operation quickly without going back to the resolvers. For example, the
2222
* particular method to run on an object may be discovered by the reflection method
2323
* resolver - it will then build a MethodExecutor that executes that method and the
24-
* MethodExecutor can be reused without needing to go back to the resolver to discover the
25-
* method again.
24+
* MethodExecutor can be reused without needing to go back to the resolver to discover
25+
* the method again.
2626
*
27-
* <p>They can become stale, and in that case should throw an AccessException - this will
28-
* cause the infrastructure to go back to the resolvers to ask for a new one.
27+
* <p>They can become stale, and in that case should throw an AccessException:
28+
* This will cause the infrastructure to go back to the resolvers to ask for a new one.
2929
*
3030
* @author Andy Clement
3131
* @since 3.0
3232
*/
3333
public interface MethodExecutor {
3434

3535
/**
36-
* Execute a command using the specified arguments, and using the specified expression
37-
* state.
36+
* Execute a command using the specified arguments, and using the specified expression state.
3837
* @param context the evaluation context in which the command is being executed
3938
* @param target the target object of the call - null for static methods
4039
* @param arguments the arguments to the executor, should match (in terms of number
41-
* and type) whatever the command will need to run
40+
* and type) whatever the command will need to run
4241
* @return the value returned from execution
4342
* @throws AccessException if there is a problem executing the command or the
44-
* MethodExecutor is no longer valid
43+
* MethodExecutor is no longer valid
4544
*/
4645
TypedValue execute(EvaluationContext context, Object target, Object... arguments) throws AccessException;
4746

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@ public interface MethodResolver {
3232

3333
/**
3434
* Within the supplied context determine a suitable method on the supplied object that
35-
* can handle the specified arguments. Return a MethodExecutor that can be used to
36-
* invoke that method (or {@code null} if no method could be found).
35+
* can handle the specified arguments. Return a {@link MethodExecutor} that can be used
36+
* to invoke that method, or {@code null} if no method could be found.
3737
* @param context the current evaluation context
3838
* @param targetObject the object upon which the method is being called
3939
* @param argumentTypes the arguments that the constructor must be able to handle
40-
* @return a MethodExecutor that can invoke the method, or null if the method cannot
41-
* be found
40+
* @return a MethodExecutor that can invoke the method, or null if the method cannot be found
4241
*/
4342
MethodExecutor resolve(EvaluationContext context, Object targetObject, String name,
4443
List<TypeDescriptor> argumentTypes) throws AccessException;

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

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,16 @@ public boolean removeConstructorResolver(ConstructorResolver resolver) {
104104
return this.constructorResolvers.remove(resolver);
105105
}
106106

107+
public void setConstructorResolvers(List<ConstructorResolver> constructorResolvers) {
108+
this.constructorResolvers = constructorResolvers;
109+
}
110+
107111
@Override
108112
public List<ConstructorResolver> getConstructorResolvers() {
109113
ensureConstructorResolversInitialized();
110114
return this.constructorResolvers;
111115
}
112116

113-
public void setConstructorResolvers(List<ConstructorResolver> constructorResolvers) {
114-
this.constructorResolvers = constructorResolvers;
115-
}
116-
117-
118117
public void addMethodResolver(MethodResolver resolver) {
119118
ensureMethodResolversInitialized();
120119
this.methodResolvers.add(this.methodResolvers.size() - 1, resolver);
@@ -125,6 +124,10 @@ public boolean removeMethodResolver(MethodResolver methodResolver) {
125124
return this.methodResolvers.remove(methodResolver);
126125
}
127126

127+
public void setMethodResolvers(List<MethodResolver> methodResolvers) {
128+
this.methodResolvers = methodResolvers;
129+
}
130+
128131
@Override
129132
public List<MethodResolver> getMethodResolvers() {
130133
ensureMethodResolversInitialized();
@@ -140,11 +143,6 @@ public BeanResolver getBeanResolver() {
140143
return this.beanResolver;
141144
}
142145

143-
public void setMethodResolvers(List<MethodResolver> methodResolvers) {
144-
this.methodResolvers = methodResolvers;
145-
}
146-
147-
148146
public void addPropertyAccessor(PropertyAccessor accessor) {
149147
ensurePropertyAccessorsInitialized();
150148
this.propertyAccessors.add(this.propertyAccessors.size() - 1, accessor);
@@ -154,17 +152,16 @@ public boolean removePropertyAccessor(PropertyAccessor accessor) {
154152
return this.propertyAccessors.remove(accessor);
155153
}
156154

155+
public void setPropertyAccessors(List<PropertyAccessor> propertyAccessors) {
156+
this.propertyAccessors = propertyAccessors;
157+
}
158+
157159
@Override
158160
public List<PropertyAccessor> getPropertyAccessors() {
159161
ensurePropertyAccessorsInitialized();
160162
return this.propertyAccessors;
161163
}
162164

163-
public void setPropertyAccessors(List<PropertyAccessor> propertyAccessors) {
164-
this.propertyAccessors = propertyAccessors;
165-
}
166-
167-
168165
public void setTypeLocator(TypeLocator typeLocator) {
169166
Assert.notNull(typeLocator, "TypeLocator must not be null");
170167
this.typeLocator = typeLocator;
@@ -232,10 +229,8 @@ public Object lookupVariable(String name) {
232229
/**
233230
* Register a {@code MethodFilter} which will be called during method resolution
234231
* for the specified type.
235-
*
236232
* <p>The {@code MethodFilter} may remove methods and/or sort the methods which
237233
* will then be used by SpEL as the candidates to look through for a match.
238-
*
239234
* @param type the type for which the filter should be called
240235
* @param filter a {@code MethodFilter}, or {@code null} to unregister a filter for the type
241236
* @throws IllegalStateException if the {@link ReflectiveMethodResolver} is not in use
@@ -244,7 +239,8 @@ public void registerMethodFilter(Class<?> type, MethodFilter filter) throws Ille
244239
ensureMethodResolversInitialized();
245240
if (this.reflectiveMethodResolver != null) {
246241
this.reflectiveMethodResolver.registerMethodFilter(type, filter);
247-
} else {
242+
}
243+
else {
248244
throw new IllegalStateException("Method filter cannot be set as the reflective method resolver is not in use");
249245
}
250246
}
@@ -272,7 +268,8 @@ private void ensureMethodResolversInitialized() {
272268
private synchronized void initializeMethodResolvers() {
273269
if (this.methodResolvers == null) {
274270
List<MethodResolver> defaultResolvers = new ArrayList<MethodResolver>();
275-
defaultResolvers.add(this.reflectiveMethodResolver = new ReflectiveMethodResolver());
271+
this.reflectiveMethodResolver = new ReflectiveMethodResolver();
272+
defaultResolvers.add(this.reflectiveMethodResolver);
276273
this.methodResolvers = defaultResolvers;
277274
}
278275
}

0 commit comments

Comments
 (0)