Just to be sure,
List<Person> personLst = [{"person:" {personName:AASH_01 , country :AUS, state :ADL, zip :null },{personName:AASH_01 , country :AUS, state :MLB, zip :null}}]
really refers to a list of valid java objects, right? Because in the current state those would be valid JavaScript Objects, but not valid Java objects.
Also, should a List<Person>
really be called with personLst.contains(String)
?
So, assuming these are valid Java objects with the correct getters and setters, and the correct method is intended, you should be able to use
personLst.forEach(p -> {
if(lstMap.containsKey(p.getState()))
p.setZip(lstMap.get(p.getState()));
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…