Skip to content

Commit 300ae84

Browse files
committed
Align setBeanResolver nullability with getBeanResolver
Includes consistent javadoc for all applicable methods. Closes gh-35371
1 parent c248f94 commit 300ae84

File tree

1 file changed

+121
-13
lines changed

1 file changed

+121
-13
lines changed

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

Lines changed: 121 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,34 +129,72 @@ public StandardEvaluationContext(@Nullable Object rootObject) {
129129
}
130130

131131

132+
/**
133+
* Specify the default root context object (including a type descriptor)
134+
* against which unqualified properties, methods, etc. should be resolved.
135+
* @param rootObject the root object to use
136+
* @param typeDescriptor a corresponding type descriptor
137+
*/
132138
public void setRootObject(@Nullable Object rootObject, TypeDescriptor typeDescriptor) {
133139
this.rootObject = new TypedValue(rootObject, typeDescriptor);
134140
}
135141

142+
/**
143+
* Specify the default root context object against which unqualified
144+
* properties, methods, etc. should be resolved.
145+
* @param rootObject the root object to use
146+
*/
136147
public void setRootObject(@Nullable Object rootObject) {
137148
this.rootObject = (rootObject != null ? new TypedValue(rootObject) : TypedValue.NULL);
138149
}
139150

151+
/**
152+
* Return the configured default root context object against which unqualified
153+
* properties, methods, etc. should be resolved (can be {@link TypedValue#NULL}).
154+
*/
140155
@Override
141156
public TypedValue getRootObject() {
142157
return this.rootObject;
143158
}
144159

160+
/**
161+
* Set the list of property accessors to use in this evaluation context.
162+
* <p>Replaces any previously configured property accessors.
163+
*/
145164
public void setPropertyAccessors(List<PropertyAccessor> propertyAccessors) {
146165
this.propertyAccessors = propertyAccessors;
147166
}
148167

168+
/**
169+
* Get the list of property accessors configured in this evaluation context.
170+
*/
149171
@Override
150172
public List<PropertyAccessor> getPropertyAccessors() {
151173
return initPropertyAccessors();
152174
}
153175

154-
public void addPropertyAccessor(PropertyAccessor accessor) {
155-
addBeforeDefault(initPropertyAccessors(), accessor);
176+
/**
177+
* Add the supplied property accessor to this evaluation context.
178+
* @param propertyAccessor the property accessor to add
179+
* @see #getPropertyAccessors()
180+
* @see #setPropertyAccessors(List)
181+
* @see #removePropertyAccessor(PropertyAccessor)
182+
*/
183+
public void addPropertyAccessor(PropertyAccessor propertyAccessor) {
184+
addBeforeDefault(initPropertyAccessors(), propertyAccessor);
156185
}
157186

158-
public boolean removePropertyAccessor(PropertyAccessor accessor) {
159-
return initPropertyAccessors().remove(accessor);
187+
/**
188+
* Remove the supplied property accessor from this evaluation context.
189+
* @param propertyAccessor the property accessor to remove
190+
* @return {@code true} if the property accessor was removed, {@code false}
191+
* if the property accessor was not configured in this evaluation context
192+
* @see #getPropertyAccessors()
193+
* @see #setPropertyAccessors(List)
194+
* @see #addPropertyAccessor(PropertyAccessor)
195+
*/
196+
public boolean removePropertyAccessor(PropertyAccessor propertyAccessor) {
197+
return initPropertyAccessors().remove(propertyAccessor);
160198
}
161199

162200
/**
@@ -198,8 +236,8 @@ public void addIndexAccessor(IndexAccessor indexAccessor) {
198236
/**
199237
* Remove the supplied index accessor from this evaluation context.
200238
* @param indexAccessor the index accessor to remove
201-
* @return {@code true} if the index accessor was removed, {@code false} if
202-
* the index accessor was not configured in this evaluation context
239+
* @return {@code true} if the index accessor was removed, {@code false}
240+
* if the index accessor was not configured in this evaluation context
203241
* @since 6.2
204242
* @see #getIndexAccessors()
205243
* @see #setIndexAccessors(List)
@@ -209,44 +247,96 @@ public boolean removeIndexAccessor(IndexAccessor indexAccessor) {
209247
return initIndexAccessors().remove(indexAccessor);
210248
}
211249

250+
/**
251+
* Set the list of constructor resolvers to use in this evaluation context.
252+
* <p>Replaces any previously configured constructor resolvers.
253+
*/
212254
public void setConstructorResolvers(List<ConstructorResolver> constructorResolvers) {
213255
this.constructorResolvers = constructorResolvers;
214256
}
215257

258+
/**
259+
* Get the list of constructor resolvers to use in this evaluation context.
260+
*/
216261
@Override
217262
public List<ConstructorResolver> getConstructorResolvers() {
218263
return initConstructorResolvers();
219264
}
220265

221-
public void addConstructorResolver(ConstructorResolver resolver) {
222-
addBeforeDefault(initConstructorResolvers(), resolver);
266+
/**
267+
* Add the supplied constructor resolver to this evaluation context.
268+
* @param constructorResolver the constructor resolver to add
269+
* @see #getConstructorResolvers()
270+
* @see #setConstructorResolvers(List)
271+
* @see #removeConstructorResolver(ConstructorResolver)
272+
*/
273+
public void addConstructorResolver(ConstructorResolver constructorResolver) {
274+
addBeforeDefault(initConstructorResolvers(), constructorResolver);
223275
}
224276

225-
public boolean removeConstructorResolver(ConstructorResolver resolver) {
226-
return initConstructorResolvers().remove(resolver);
277+
/**
278+
* Remove the supplied constructor resolver from this evaluation context.
279+
* @param constructorResolver the constructor resolver to remove
280+
* @return {@code true} if the constructor resolver was removed, {@code false}
281+
* if the constructor resolver was not configured in this evaluation context
282+
< * @see #getConstructorResolvers()
283+
* @see #setConstructorResolvers(List)
284+
* @see #addConstructorResolver(ConstructorResolver)
285+
*/
286+
public boolean removeConstructorResolver(ConstructorResolver constructorResolver) {
287+
return initConstructorResolvers().remove(constructorResolver);
227288
}
228289

290+
/**
291+
* Set the list of method resolvers to use in this evaluation context.
292+
* <p>Replaces any previously configured method resolvers.
293+
*/
229294
public void setMethodResolvers(List<MethodResolver> methodResolvers) {
230295
this.methodResolvers = methodResolvers;
231296
}
232297

298+
/**
299+
* Get the list of method resolvers to use in this evaluation context.
300+
*/
233301
@Override
234302
public List<MethodResolver> getMethodResolvers() {
235303
return initMethodResolvers();
236304
}
237305

238-
public void addMethodResolver(MethodResolver resolver) {
239-
addBeforeDefault(initMethodResolvers(), resolver);
306+
/**
307+
* Add the supplied method resolver to this evaluation context.
308+
* @param methodResolver the method resolver to add
309+
* @see #getMethodResolvers()
310+
* @see #setMethodResolvers(List)
311+
* @see #removeMethodResolver(MethodResolver)
312+
*/
313+
public void addMethodResolver(MethodResolver methodResolver) {
314+
addBeforeDefault(initMethodResolvers(), methodResolver);
240315
}
241316

317+
/**
318+
* Remove the supplied method resolver from this evaluation context.
319+
* @param methodResolver the method resolver to remove
320+
* @return {@code true} if the method resolver was removed, {@code false}
321+
* if the method resolver was not configured in this evaluation context
322+
* @see #getMethodResolvers()
323+
* @see #setMethodResolvers(List)
324+
* @see #addMethodResolver(MethodResolver)
325+
*/
242326
public boolean removeMethodResolver(MethodResolver methodResolver) {
243327
return initMethodResolvers().remove(methodResolver);
244328
}
245329

246-
public void setBeanResolver(BeanResolver beanResolver) {
330+
/**
331+
* Set the {@link BeanResolver} to use for looking up beans, if any.
332+
*/
333+
public void setBeanResolver(@Nullable BeanResolver beanResolver) {
247334
this.beanResolver = beanResolver;
248335
}
249336

337+
/**
338+
* Get the configured {@link BeanResolver} for looking up beans, if any.
339+
*/
250340
@Override
251341
@Nullable
252342
public BeanResolver getBeanResolver() {
@@ -284,11 +374,17 @@ public TypeLocator getTypeLocator() {
284374
return this.typeLocator;
285375
}
286376

377+
/**
378+
* Set the {@link TypeConverter} for value conversion.
379+
*/
287380
public void setTypeConverter(TypeConverter typeConverter) {
288381
Assert.notNull(typeConverter, "TypeConverter must not be null");
289382
this.typeConverter = typeConverter;
290383
}
291384

385+
/**
386+
* Get the configured {@link TypeConverter} for value conversion.
387+
*/
292388
@Override
293389
public TypeConverter getTypeConverter() {
294390
if (this.typeConverter == null) {
@@ -297,21 +393,33 @@ public TypeConverter getTypeConverter() {
297393
return this.typeConverter;
298394
}
299395

396+
/**
397+
* Set the {@link TypeComparator} for comparing pairs of objects.
398+
*/
300399
public void setTypeComparator(TypeComparator typeComparator) {
301400
Assert.notNull(typeComparator, "TypeComparator must not be null");
302401
this.typeComparator = typeComparator;
303402
}
304403

404+
/**
405+
* Get the configured {@link TypeComparator} for comparing pairs of objects.
406+
*/
305407
@Override
306408
public TypeComparator getTypeComparator() {
307409
return this.typeComparator;
308410
}
309411

412+
/**
413+
* Set the {@link OperatorOverloader} for mathematical operations.
414+
*/
310415
public void setOperatorOverloader(OperatorOverloader operatorOverloader) {
311416
Assert.notNull(operatorOverloader, "OperatorOverloader must not be null");
312417
this.operatorOverloader = operatorOverloader;
313418
}
314419

420+
/**
421+
* Get the configured {@link OperatorOverloader} for mathematical operations.
422+
*/
315423
@Override
316424
public OperatorOverloader getOperatorOverloader() {
317425
return this.operatorOverloader;

0 commit comments

Comments
 (0)