I have a data class. Fields can be collections, primitives, references etc. I have to check the equality of two instances of this class. Generally we override equals method for this purpose. But usecase is such that properties which are to be compared may vary.
So say, class A has properties:
int name:
int age:
List<String> hobbies;
In one invocation I may have to check equality based on name,age, and for another invocation I may have to check equality for name, hobbies.
What is best practice to achieve this?