I\'ve got a map containing some keys (Strings) and values (POJOs)
I want to iterate through this map and alter some of the data in the POJO.
The current code
For such purposes you should use the collection views a map exposes:
Example: convert the values of all keys that contain an upperscore to uppercase
for(Map.Entry entry:map.entrySet()){
if(entry.getKey().contains("_"))
entry.setValue(entry.getValue().toUpperCase());
}
Actually, if you just want to edit the value objects, do it using the values collection. I assume your map is of type
:
for(Object o: map.values()){
if(o instanceof MyBean){
((Mybean)o).doStuff();
}
}