【发布时间】:2014-12-02 08:47:58
【问题描述】:
我的结构如下
Parameter -> Condition -> Rule
假设我需要创建一个Business rule、Customer Age > 18
我有两个参数,Customer Age (P1) and 18(P2),其中P1 is Field Parameter (Ognl) 和P2 is constant Parameter 与value 18。
所以我的Condition 现在是Customer Age > 18 和我的Rule。
问题说明:避免用户创建重复的参数/条件和规则。
解决方案:Constant Parameters, Field Parameters etc我可以检查数据库并比较是否已经存在。
现在条件对我来说,
Customer Age > 18 和 18 < Customer Age 在业务术语上是相同的。
上述情况可能更复杂。
(a + b) * (c + d) is same as (b + a) * (d + c)
我需要验证上面的表达式。
第一种方法 - 从 DB 加载所有表达式(可以是 10000 的)并比较 using Stack/Tree Structure,这真的会扼杀我的目标。
第二种方法 - 我正在考虑建立完整的权力,比如说hashcode generator,或者我们可以对每个表达式说一个int value(还考虑运算符/括号)。这个值的生成方式应该能够验证上面的表达式。
意味着a + b 和b + a 应该生成相同的int value,而a - b 和b - a 应该生成不同的。
【问题讨论】:
标签: java string validation expression duplication