This is my object structure.
List<Customer> customerSelection = new ArrayList<Customer>();
Customer c1 = new Customer();
Customer c2 = new Customer();
c1.setName("Syed");
c2.setName("Syed");
Map<String,String> locationList1 = new HashMap<String,String>();
Map<String,String> locationList2 = new HashMap<String,String>();
locationList1.put("DXB", "Dubai");
locationList1.put("AUH", "Abudhabi");
locationList2.put("DXB", "Dubai");
locationList2.put("BAH", "Bahrain");
c1.setLocationList(locationList1);
c2.setLocationList(locationList2);
customerSelection.add(c1);
customerSelection.add(c2);
Here I want to validate if a customer is having preferred duplicate location, I should throw an error message. Any ideas on optimized solution?
Here Syed is having dubai as as location in location list which is invalid.
Mapinstead of aListfor the locations?