The simple builder structures of expression
(v1 = 'val1' OR v2 = 100) AND (v3 not in ('v1', 'v2', 'v3') OR v4 > 100)
condition1 := And(
Extr(
func(val *filter) *filterV12 {
return &filterV12{v1: val.v1, v2: val.v2}
},
Or(
Func(func(val *filterV12) bool {
return val.v1 == "val1"
}),
Func(func(val *filterV12) bool {
return val.v2 == 100
}),
),
),
Or(
Not(Func(func(val *filter) bool {
var arr = []string{"v1", "v2", "v3"}
for _, v := range arr {
if v == val.v3 {
return true
}
}
return false
})),
Func(func(val *filter) bool {
return val.v4 > 100
}),
),
)
if condition1.True(&filter{...}) {
// DO SOMETHING ...
}
Combination of condition expressions
conditionNew := Extr(
func(ctx any) *filter {
return &filter{...}
},
And(
condition1,
Or(
condition2,
condition3,
),
),
)