java - Finding duplicate expressions/parameters -
i have structure below
parameter -> condition -> rule
let need create business rule
, customer age > 18
i have 2 parameters, customer age (p1) , 18(p2)
, p1 field parameter (ognl)
, p2 constant parameter
value 18
.
so condition
, customer age > 18
, rule
.
problem statement : avoid user creating duplicate parameter/condition , rules.
solution : constant parameters, field parameters etc
can check in db , compare if present.
now condition me,
customer age > 18
, 18 < customer age
same in business terms.
the above cases can more complex.
(a + b) * (c + d) same (b + a) * (d + c)
i need validate above expressions.
first approach - load expression db (can 10000's) , compare using stack/tree structure
, kill objective.
second approach - thinking of building power full, let hashcode generator
or can 1 int value
against every expression (considering operators/brackets also). value should generated in such way validates above expression.
means a + b
, b + a
should generate same int value
, , a - b
, b - a
should generate different.
maybe simplified version of first approach: filtering relevant expressions looking similar content insert database?
if know insert customer age
can find expressions containing parameter , build stack/tree based on reduced set of expressions.
Comments
Post a Comment