Class SimpleEvaluationContext.Builder
- Enclosing class:
SimpleEvaluationContext
SimpleEvaluationContext.- Since:
- 4.3.15
- Author:
- Rossen Stoyanchev, Juergen Hoeller, Sam Brannen
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Disable assignment within expressions evaluated by this evaluation context.Indicate that compilation is supported within expressions evaluated by this evaluation context.withConversionService(ConversionService conversionService) Register a customConversionService.withConverter(Class<S> sourceType, Class<T> targetType, Converter<? super S, ? extends T> converter) Register aConverterfor the specified source and target types, in addition to the converters of the defaultConversionService.withIndexAccessors(IndexAccessor... indexAccessors) Register the specifiedIndexAccessordelegates.Register aDataBindingMethodResolverfor instance method invocation purposes (i.e.withMethodResolvers(MethodResolver... resolvers) Register the specifiedMethodResolverdelegates for a combination of property access and method resolution.withRootObject(Object rootObject) Specify a default root object to resolve against.withTypeConverter(TypeConverter converter) Register a customTypeConverter.withTypedRootObject(Object rootObject, TypeDescriptor typeDescriptor) Specify a typed root object to resolve against.
-
Method Details
-
withAssignmentDisabled
Disable assignment within expressions evaluated by this evaluation context.- Since:
- 5.3.38
- See Also:
-
withCompilationSupported
Indicate that compilation is supported within expressions evaluated by this evaluation context.By default, compilation is not supported in
SimpleEvaluationContext. Call this method to opt in to compilation — for example, when evaluating trusted expressions where performance is critical.WARNING: Opting in to compilation for expressions from untrusted sources removes the safety guards supported in interpreted mode.
- Since:
- 7.0.9
- See Also:
-
withIndexAccessors
Register the specifiedIndexAccessordelegates.- Parameters:
indexAccessors- the index accessors to use- Since:
- 6.2
-
withMethodResolvers
Register the specifiedMethodResolverdelegates for a combination of property access and method resolution.- Parameters:
resolvers- the resolver delegates to use- See Also:
-
withInstanceMethods
Register aDataBindingMethodResolverfor instance method invocation purposes (i.e. not supporting static methods) in addition to the specified property accessors, typically in combination with aDataBindingPropertyAccessor.- See Also:
-
withConversionService
Register a customConversionService.By default a
StandardTypeConverterbacked by a restrictedDefaultConversionServiceis used, which does not convert a value by reflectively invoking a constructor, a static factory method, or another method on an arbitrary type. See the class-level documentation for details.WARNING: The supplied
ConversionServiceis used as-is. If it converts values by reflectively invoking constructors or methods — as a standardDefaultConversionServicedoes — every type to which a value may be converted during evaluation must be designed with the same care as any other object reachable from an expression. See the Security Considerations section of the Spring Framework reference documentation for details.To support conversion to additional types, consider registering dedicated converters via
withConverter(Class, Class, Converter)instead.- See Also:
-
withTypeConverter
Register a customTypeConverter.By default a
StandardTypeConverterbacked by a restrictedDefaultConversionServiceis used. See the class-level documentation for details.WARNING: The supplied
TypeConverteris used as-is. For example, aStandardTypeConvertercreated via its no-arg constructor delegates to the sharedDefaultConversionService, which converts values by reflectively invoking constructors and methods. SeewithConversionService(ConversionService)for details.To support conversion to additional types, consider registering dedicated converters via
withConverter(Class, Class, Converter)instead.- See Also:
-
withConverter
public <S,T> SimpleEvaluationContext.Builder withConverter(Class<S> sourceType, Class<T> targetType, Converter<? super S, ? extends T> converter) Register aConverterfor the specified source and target types, in addition to the converters of the defaultConversionService.This is the recommended way to support a conversion which the default
ConversionServicedoes not support — for example,withConverter(String.class, ZoneId.class, ZoneId::of). See the class-level documentation for details.This method may be invoked multiple times to register multiple converters; however, it cannot be combined with
withConversionService(ConversionService)orwithTypeConverter(TypeConverter), in which casebuild()throws anIllegalStateException.- Parameters:
sourceType- the source type to convert fromtargetType- the target type to convert toconverter- the converter to use- Since:
- 7.0.10
- See Also:
-
withRootObject
Specify a default root object to resolve against.Default is none, expecting an object argument at evaluation time.
- See Also:
-
withTypedRootObject
public SimpleEvaluationContext.Builder withTypedRootObject(Object rootObject, TypeDescriptor typeDescriptor) Specify a typed root object to resolve against.Default is none, expecting an object argument at evaluation time.
- See Also:
-
build
-