In one of my past projects there was a need to perform dynamic computations on Java-Objects. The user was able to input some complex formulas, which had to be interpreted.
I could write of course a custom language for this purpose, but because of my laziness I just passed the objects as well as the formula to groovy, which interpreted and executed the formula for me.
During the review of the new JSR-310 (the Date And Time API for Java) and especially the fluent api, I got the next idea: simulation of the operator overloading for Java-Objects.
So I wanted to do something like this:
BigDecimal two = new BigDecimal(2);
BigDecimal three = new BigDecimal(3);
BigDecimal minusOne = Overload.eval("p1-p2", two,three);
I materialized the idea in the o24j opensource project. It already works - the sources are checked in.
Then no additional libraries would be required.
o24j works with JSR-310 as well :-).
Cloudy Jakarta EE and MicroProfile: Microservices, Clouds and Beyond Jakarta EE / MicroProfile airhacks workshops at MUC airport, Winter Edition
airhacks.fm the podcast:
Stay in touch: airhacks.news.