Recently, I have been working with Predicates.
I'm modelling some stuff for a bank but I needed to present updates and changes to the handwritten rules regularly. I don't know about you but wouldn't be nice if we could print the Predicate and not getting something like:
net.objectlab.kit.util.excel.ExcelWorkbookTest$$Lambda$1/868693306@13221655
Therefore, here comes the PrintablePredicate
class in the next release of ObjectLab Kit.
See PrintablePredicate.java
The idea is to create an implementation of a Predicate and allow you to give it a name and the values it is comparing against. We also support AND, OR and NEGATE as per a Predicate.
Let's imagine a small model, a financial Instrument 'Asset' and some basic Predicates. Imagine that we create a predicate that detects instruments that are either Bonds or Commodities but that they should also be Active.
Using PrintablePredicate, I can combine 2 predicates and when I print the predicate (in an Excel spreadsheet that I generate automatically, more on that later) I can see a nice string "AssetClass in (Bond, Commodities) AND Active". Here is the code for it:
This tiny class will come with ObjectLab Kit 1.4.1. Enjoy!