I am trying to implement a custom class that should behave like Boolean
in Jexl expressions:
Example:
Object result = jexl.createExpression("a || b").evaluate(context)
Where a
and b
are instances of a custom class that contains an boolean
and extra information that should be carried through the evaluated expresssion so that it can be accessed in the end in result
.
I have read that Jexl3 should support operator overloading and it seems to have all the necessary structures for defining own operators for custom classes - however I am unable to understand what steps are necessary for doing so.
I already tries to extend Uberspect
and JexlArithmetic
by custom implementations, however I only found out that using toBoolean
I can convert my custom objects to Boolean
(which makes result
a Boolean
- hence I loose all the extra information).
How to use/extend Jexl properly to provide boolean operators for custom classes?