I'm developping an application spring-boot, I want to compare to users object
public class User {
private String name;
private String firstName;
private String codeEmpl;
private String codeCompany;
// Getters & setters
}
When I update user I got from the frontend only the modified fields then I have to compare these fields with the saved fields in database. The copy the saved information on the User that I have received. My question is how I can compare only the dynamique fields received from frontend ? and how I can copy only the saved information on the received object ?
Concerning Compare: I override the equals but the equals compare all the fields one by one.
Concerning Copy: I used
BeanUtils.copyProperties(orig, dest);
But this it copy all fields
Would you have any ideas ?
Best regards