java.lang.Object
org.miaixz.bus.cache.support.SpelCalculator
SpEL表达式计算器
提供SpEL(Spring Expression Language)表达式的计算功能,用于解析和执行SpEL表达式。 支持带上下文和不带上下文的表达式计算,用于缓存注解中的条件判断和键值生成。
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectcalcSpelValueWithContext(String spel, String[] argNames, Object[] argValues, Object defaultValue) 计算带上下文的SpEL表达式值static ObjectcalcSpelWithNoContext(String spel, Object defaultValue) 计算不带上下文的SpEL表达式值
-
Constructor Details
-
SpelCalculator
public SpelCalculator()
-
-
Method Details
-
calcSpelValueWithContext
public static Object calcSpelValueWithContext(String spel, String[] argNames, Object[] argValues, Object defaultValue) 计算带上下文的SpEL表达式值在给定的上下文中计算SpEL表达式的值,上下文包含方法参数名和参数值的映射关系。 支持原始参数名和生成的xArg格式的参数名。
- Parameters:
spel- SpEL表达式字符串argNames- 参数名数组argValues- 参数值数组defaultValue- 默认值,当表达式为空时返回- Returns:
- 表达式计算结果
-
calcSpelWithNoContext
计算不带上下文的SpEL表达式值在给定的默认对象上下文中计算SpEL表达式的值,主要用于处理对象属性访问。
- Parameters:
spel- SpEL表达式字符串defaultValue- 默认值,当表达式为空时返回- Returns:
- 表达式计算结果
-