Предупреждение FindBugs: неэффективное использование итератора keySet вместо итератора entrySet
Пожалуйста, обратитесь к следующему методу:
public Set<LIMSGridCell> getCellsInColumn(String columnIndex){
Map<String,LIMSGridCell> cellsMap = getCellsMap();
Set<LIMSGridCell> cells = new HashSet<LIMSGridCell>();
Set<String> keySet = cellsMap.keySet();
for(String key: keySet){
if(key.startsWith(columnIndex)){
cells.add(cellsMap.get(key));
}
}
return cells;
}
FindBugs выдают это сообщение:
"Inefficient use of keySet iterator instead of entrySet iterator This method accesses the value of a Map entry, using a key that was retrieved from a keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the Map.get(key) lookup."