Open
Description
Use Case
My use case is for the Equivalence class and is to enable checking against multiple nested fields. It isn't yet supported I'd like to add support for it. There's an added benefit too - it would reduce and simplify the amount of client code needed to create Equivalence objects.
Issues
- There is an Equivalence.onResultOf() method but it only takes one Function, if you only need to test one field that's fine, but if you want to test multiple fields then you have to create your own Functions that delegate to each in turn.
- The onResultOf() method can be chained, but it creates an extra object for each Function tested. It should be possible to create only one object for multiple Functions.
- The code needed to create the chain is quite verbose and could be reduced and simplified with the right method declarations.
Solution
Add factory methods to create Equivalence objects that take multiple Functions or multiple Equivalences. This will solve all 3 issues above and would be invoked something like eg.
ofFields(Class1::getField1, Class1::getField2);
or
ofSubFields(Class1::getField1, ofFields(Field1::getSubField1, Field1::getSubField2));
Any thoughts on this would be much appreciated
Activity