Fetching data from RestUI which comes in com.ow.vo.computer.ApplicationUsage.
Fetching data from Database.
Compare each content as given below
public void compare(com.ow.vo.computer.ApplicationUsage src, ApplicationUsage dest) {
if(!Objects.equals(src.getApplicationItemCost(), dest.getApplicationItemCost())) {
dest.setApplicationItenCost(src.getApplicationItemCost);
}
if(!Objects.equals(src.getAvgUsageTime(), dest.getAvgUsageTime())) {
}
if(!Objects.equals(src.getBundleApplicationId(), dest.getBundleApplicationId())) {
}
if(!Objects.equals(src.getBundleApplicationName(), dest.getBundleApplicationName())) {
}
if(!Objects.equals(src.getDiscoveredDate(), dest.getDiscoveredDate())) {
}
.
.
.
If any update then only update it into database else do not.
The structure of both src and dest is almost same with difference in date types like Source have String and dest have Date.
Could anyone suggest more elegant way or design pattern to handle this situation in place of comparison each field one by one.
Aucun commentaire:
Enregistrer un commentaire