I have two objects, each of which have tens of fields:
Class1 {
int firstProperty;
String secondProperty;
...
}
Class2 {
int propertyOne;
St
Comparing objects of different classes by specific fields is exactly the scenario that https://github.com/nejckorasa/compare-utils solves.
Example:
ObjectCmp.equalEqualityPairs(
object1,
object2,
Arrays.asList(
EqualityPair.of(o1 -> o1.getFirstProperty(), o2 -> o2.getPropertyOne()),
EqualityPair.of(o1 -> o1.getSecondProperty(), o2 -> o2.getPropertyTwo())));
Take a look, it might be useful!