I have structure as below
Parameter -> Condition -> Rule
Let say i need to create a Business rule
, Customer Age > 18
I have two parameters, Customer Age (P1) and 18(P2)
, where P1 is Field Parameter (Ognl)
and P2 is constant Parameter
with value 18
.
So my Condition
now is , Customer Age > 18
and so as my Rule
.
Problem Statement : Avoid user from creating duplicate parameter/condition and rules.
Solution : Constant Parameters, Field Parameters etc
i can check in DB and compare if already present.
Now condition for me,
Customer Age > 18
and 18 < Customer Age
is same in business terms.
The above cases can be more complex.
(a + b) * (c + d) is same as (b + a) * (d + c)
I need to validate the above expressions.
First Approach - Load all expression from DB (Can be 10000's) and compare using Stack/Tree Structure
, which will really kill my objective.
Second Approach - I was thinking of building power full, let say hashcode generator
or we can say one int value
against every expression (considering operators/brackets also). this value should be generated in such a way that it validates above expression.
Means a + b
and b + a
should generate same int value
, and a - b
and b - a
should generate different.