I tried many ways but seemed jexl doesn't work well with collections and lambda expression. Essentially I have a list of json objects and I want to have a customized utility function set into jexl context so as the expression to be
"filter(collections, 'a -> a.age > 10')"
While collection is a list of Person(name, age) objects, filter is the customized function to achieve the similar filter logic in coding language while 'a-> a.age > 10" is the condition clause.
But now matter how hard I try, it seems jexl always have issues to parse the 'a -> a.age > 10" as this is lambda.
I'm getting either parsing error or undefined variable error to a point not sure if anyone achieved to write collection related customized function in jexl
Tried to have a function takes collection, either string or a condition clause not work. Resulting always in undefined variable or parse error from jexl.
JEXL requires a bit of configuration and customization to adapt to any use case. To allow collections (or streams) to be filtered by expressions, there is an example in StreamTest.java; have a look at CollectionContext and testURICollection, this should point you in the right direction.
Beware that permissions are a lot more constrained by default in JEXL 3.3 and need to be properly defined for scripts to run properly. (see JexlPermissions)
Hope this helps.