Evaluates the #{...} expressions of @Value strings, after their
${...} placeholders are resolved.
An application context installs the SpEL-based
StandardBeanExpressionResolver, so @Value('#{...}') works without
setup. Implement this interface only to evaluate expressions in another
way; set the standard one yourself on a factory used without a context.
// A bare factory gets SpEL in @Value, as in a context.
factory.beanExpressionResolver = StandardBeanExpressionResolver();
// Or a resolver of your own: "#{name}" reads a feature flag.
class FlagResolver implements BeanExpressionResolver {
FlagResolver(this.flags);
final Map<String, bool> flags;
@override
Object? evaluate(String value, BeanFactory beanFactory) =>
value.startsWith('#{') && value.endsWith('}')
? flags[value.substring(2, value.length - 1)]
: value;
}
Spring (Java):
factory.setBeanExpressionResolver(
new StandardBeanExpressionResolver(classLoader));
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
evaluate(
String value, BeanFactory beanFactory) → Object? -
The value of
value, a@Valuestring whose placeholders are already resolved and which may contain#{...}; a string without an expression is returned as it is. Other beans are reachable throughbeanFactory. The result is then converted to the injection point's type. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited