I have a class that with a long list of private variables like this
class ManyVariables {
private int var1;
private int var2;
//....
private int var49;
public int getVar1(){};
public int getVar2(){};
//....
public int getVar49(){};
}
I am trying to override the equals
method so that it compares all the variables of two instances, however, since the list of variables is so long typing them all out manually is really not ideal. Is there a way to get them all into a Stream
object and use Stream
's pipeline to do the comparison? I know I can also use reflection but I'd rather not set the private fields to accessible at run time. Thanks!