LambdaRule
- Type class
- Package:
com.euonia.osba.rules - Author: damon(zhaorong@outlook.com)
- Type Parameters:
<T>— 被验证的属性值的类型 - Extends:
RuleBase
Constructors¶
LambdaRule(PropertyInfo<T> property)¶
Parameters:
- property (PropertyInfo<T>): 要验证的属性信息
LambdaRule(PropertyInfo<T> property, BiFunction<T, RuleContext, Boolean> function, String message)¶
Parameters:
- property (PropertyInfo<T>): 要验证的属性信息
- function (BiFunction<T, RuleContext, Boolean>): 验证函数,接受属性值和规则上下文,返回布尔值指示验证是否通过
- message (String): 验证失败时的静态错误消息
LambdaRule(PropertyInfo<T> property, BiFunction<T, RuleContext, Boolean> function, Function<T, String> messageFactory)¶
Parameters:
- property (PropertyInfo<T>): 要验证的属性信息
- function (BiFunction<T, RuleContext, Boolean>): 验证函数,接受属性值和规则上下文,返回布尔值指示验证是否通过
- messageFactory (Function<T, String>): 消息工厂,根据属性值生成错误消息
Methods¶
execute(RuleContext context): void¶
Parameters:
- context (RuleContext): 规则上下文,包含有关规则执行环境的信息,如目标对象和属性值。
check(BiFunction<T, RuleContext, Boolean> function): LambdaRule<T>¶
Parameters:
- function (BiFunction<T, RuleContext, Boolean>): 一个 BiFunction,接受属性值和规则上下文,返回布尔值
Returns: LambdaRule<T> — 当前 LambdaRule 实例,以便进行链式调用
message(Function<T, String> messageFactory): LambdaRule<T>¶
Parameters:
- messageFactory (Function<T, String>): 一个函数,接受属性值并返回错误消息字符串
Returns: LambdaRule<T> — 当前 LambdaRule 实例,以便进行链式调用
message(String message): LambdaRule<T>¶
Parameters:
- message (String): 静态错误消息
Returns: LambdaRule<T> — 当前 LambdaRule 实例,以便进行链式调用
Static Methods¶
of(PropertyInfo<T> property): LambdaRule<T>¶
Type Parameters:
- <T>: 属性的类型
Parameters:
- property (PropertyInfo<T>): 要验证的属性信息
Returns: LambdaRule<T> — 一个新的 LambdaRule 实例