Browse Source

Align setBeanResolver nullability with getBeanResolver

Includes consistent javadoc for all applicable methods.

Closes gh-35371
pull/35405/head
Juergen Hoeller 4 months ago
parent
commit
300ae841ce
  1. 134
      spring-expression/src/main/java/org/springframework/expression/spel/support/StandardEvaluationContext.java

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

@ -129,34 +129,72 @@ public class StandardEvaluationContext implements EvaluationContext { @@ -129,34 +129,72 @@ public class StandardEvaluationContext implements EvaluationContext {
}
/**
* Specify the default root context object (including a type descriptor)
* against which unqualified properties, methods, etc. should be resolved.
* @param rootObject the root object to use
* @param typeDescriptor a corresponding type descriptor
*/
public void setRootObject(@Nullable Object rootObject, TypeDescriptor typeDescriptor) {
this.rootObject = new TypedValue(rootObject, typeDescriptor);
}
/**
* Specify the default root context object against which unqualified
* properties, methods, etc. should be resolved.
* @param rootObject the root object to use
*/
public void setRootObject(@Nullable Object rootObject) {
this.rootObject = (rootObject != null ? new TypedValue(rootObject) : TypedValue.NULL);
}
/**
* Return the configured default root context object against which unqualified
* properties, methods, etc. should be resolved (can be {@link TypedValue#NULL}).
*/
@Override
public TypedValue getRootObject() {
return this.rootObject;
}
/**
* Set the list of property accessors to use in this evaluation context.
* <p>Replaces any previously configured property accessors.
*/
public void setPropertyAccessors(List<PropertyAccessor> propertyAccessors) {
this.propertyAccessors = propertyAccessors;
}
/**
* Get the list of property accessors configured in this evaluation context.
*/
@Override
public List<PropertyAccessor> getPropertyAccessors() {
return initPropertyAccessors();
}
public void addPropertyAccessor(PropertyAccessor accessor) {
addBeforeDefault(initPropertyAccessors(), accessor);
/**
* Add the supplied property accessor to this evaluation context.
* @param propertyAccessor the property accessor to add
* @see #getPropertyAccessors()
* @see #setPropertyAccessors(List)
* @see #removePropertyAccessor(PropertyAccessor)
*/
public void addPropertyAccessor(PropertyAccessor propertyAccessor) {
addBeforeDefault(initPropertyAccessors(), propertyAccessor);
}
public boolean removePropertyAccessor(PropertyAccessor accessor) {
return initPropertyAccessors().remove(accessor);
/**
* Remove the supplied property accessor from this evaluation context.
* @param propertyAccessor the property accessor to remove
* @return {@code true} if the property accessor was removed, {@code false}
* if the property accessor was not configured in this evaluation context
* @see #getPropertyAccessors()
* @see #setPropertyAccessors(List)
* @see #addPropertyAccessor(PropertyAccessor)
*/
public boolean removePropertyAccessor(PropertyAccessor propertyAccessor) {
return initPropertyAccessors().remove(propertyAccessor);
}
/**
@ -198,8 +236,8 @@ public class StandardEvaluationContext implements EvaluationContext { @@ -198,8 +236,8 @@ public class StandardEvaluationContext implements EvaluationContext {
/**
* Remove the supplied index accessor from this evaluation context.
* @param indexAccessor the index accessor to remove
* @return {@code true} if the index accessor was removed, {@code false} if
* the index accessor was not configured in this evaluation context
* @return {@code true} if the index accessor was removed, {@code false}
* if the index accessor was not configured in this evaluation context
* @since 6.2
* @see #getIndexAccessors()
* @see #setIndexAccessors(List)
@ -209,44 +247,96 @@ public class StandardEvaluationContext implements EvaluationContext { @@ -209,44 +247,96 @@ public class StandardEvaluationContext implements EvaluationContext {
return initIndexAccessors().remove(indexAccessor);
}
/**
* Set the list of constructor resolvers to use in this evaluation context.
* <p>Replaces any previously configured constructor resolvers.
*/
public void setConstructorResolvers(List<ConstructorResolver> constructorResolvers) {
this.constructorResolvers = constructorResolvers;
}
/**
* Get the list of constructor resolvers to use in this evaluation context.
*/
@Override
public List<ConstructorResolver> getConstructorResolvers() {
return initConstructorResolvers();
}
public void addConstructorResolver(ConstructorResolver resolver) {
addBeforeDefault(initConstructorResolvers(), resolver);
/**
* Add the supplied constructor resolver to this evaluation context.
* @param constructorResolver the constructor resolver to add
* @see #getConstructorResolvers()
* @see #setConstructorResolvers(List)
* @see #removeConstructorResolver(ConstructorResolver)
*/
public void addConstructorResolver(ConstructorResolver constructorResolver) {
addBeforeDefault(initConstructorResolvers(), constructorResolver);
}
public boolean removeConstructorResolver(ConstructorResolver resolver) {
return initConstructorResolvers().remove(resolver);
/**
* Remove the supplied constructor resolver from this evaluation context.
* @param constructorResolver the constructor resolver to remove
* @return {@code true} if the constructor resolver was removed, {@code false}
* if the constructor resolver was not configured in this evaluation context
< * @see #getConstructorResolvers()
* @see #setConstructorResolvers(List)
* @see #addConstructorResolver(ConstructorResolver)
*/
public boolean removeConstructorResolver(ConstructorResolver constructorResolver) {
return initConstructorResolvers().remove(constructorResolver);
}
/**
* Set the list of method resolvers to use in this evaluation context.
* <p>Replaces any previously configured method resolvers.
*/
public void setMethodResolvers(List<MethodResolver> methodResolvers) {
this.methodResolvers = methodResolvers;
}
/**
* Get the list of method resolvers to use in this evaluation context.
*/
@Override
public List<MethodResolver> getMethodResolvers() {
return initMethodResolvers();
}
public void addMethodResolver(MethodResolver resolver) {
addBeforeDefault(initMethodResolvers(), resolver);
/**
* Add the supplied method resolver to this evaluation context.
* @param methodResolver the method resolver to add
* @see #getMethodResolvers()
* @see #setMethodResolvers(List)
* @see #removeMethodResolver(MethodResolver)
*/
public void addMethodResolver(MethodResolver methodResolver) {
addBeforeDefault(initMethodResolvers(), methodResolver);
}
/**
* Remove the supplied method resolver from this evaluation context.
* @param methodResolver the method resolver to remove
* @return {@code true} if the method resolver was removed, {@code false}
* if the method resolver was not configured in this evaluation context
* @see #getMethodResolvers()
* @see #setMethodResolvers(List)
* @see #addMethodResolver(MethodResolver)
*/
public boolean removeMethodResolver(MethodResolver methodResolver) {
return initMethodResolvers().remove(methodResolver);
}
public void setBeanResolver(BeanResolver beanResolver) {
/**
* Set the {@link BeanResolver} to use for looking up beans, if any.
*/
public void setBeanResolver(@Nullable BeanResolver beanResolver) {
this.beanResolver = beanResolver;
}
/**
* Get the configured {@link BeanResolver} for looking up beans, if any.
*/
@Override
@Nullable
public BeanResolver getBeanResolver() {
@ -284,11 +374,17 @@ public class StandardEvaluationContext implements EvaluationContext { @@ -284,11 +374,17 @@ public class StandardEvaluationContext implements EvaluationContext {
return this.typeLocator;
}
/**
* Set the {@link TypeConverter} for value conversion.
*/
public void setTypeConverter(TypeConverter typeConverter) {
Assert.notNull(typeConverter, "TypeConverter must not be null");
this.typeConverter = typeConverter;
}
/**
* Get the configured {@link TypeConverter} for value conversion.
*/
@Override
public TypeConverter getTypeConverter() {
if (this.typeConverter == null) {
@ -297,21 +393,33 @@ public class StandardEvaluationContext implements EvaluationContext { @@ -297,21 +393,33 @@ public class StandardEvaluationContext implements EvaluationContext {
return this.typeConverter;
}
/**
* Set the {@link TypeComparator} for comparing pairs of objects.
*/
public void setTypeComparator(TypeComparator typeComparator) {
Assert.notNull(typeComparator, "TypeComparator must not be null");
this.typeComparator = typeComparator;
}
/**
* Get the configured {@link TypeComparator} for comparing pairs of objects.
*/
@Override
public TypeComparator getTypeComparator() {
return this.typeComparator;
}
/**
* Set the {@link OperatorOverloader} for mathematical operations.
*/
public void setOperatorOverloader(OperatorOverloader operatorOverloader) {
Assert.notNull(operatorOverloader, "OperatorOverloader must not be null");
this.operatorOverloader = operatorOverloader;
}
/**
* Get the configured {@link OperatorOverloader} for mathematical operations.
*/
@Override
public OperatorOverloader getOperatorOverloader() {
return this.operatorOverloader;

Loading…
Cancel
Save