I have a class with variables for old data and new data.
Example:
class Person{
String newAddress;
int newMobileNumber;
String newOfficeId;
// many fields like this (atleast 15 fields)
String oldAddress;
int oldMobileNumber;
String oldOfficeId;
// many fields like this (atleast 15 fields)
//getters and setters of all the fields.
}
What I am doing is on click of button storing old data and new data in a table consisting column with the same name as that of fields(for keeping track of old data)
But if all the oldFields are equal to newFields I want to avoid to avoid database operation.
one way of doing this is using many if conditions. like this,
if(oldAddress.equals(newAddress)){
flag = true;
}
if(oldMobileNumber.equals(newMobileNumber)){
flag = true;
}
So I'll need many such if() ,I don't find this solution that good. How can I do this in a better way?
Aucun commentaire:
Enregistrer un commentaire