I have the following class:
public class Item {
int id;
String name;
// few other fields, contructor, getters and setters
}
I have
You want to find at most one item for each given id and do something with the found item, right? A bit more performance improvement:
Set idsToLookup = new HashSet<>(getIdsToLookup()); // replace list with Set
items.stream()
.filter(e -> idsToLookup.remove(e.getId()))
.forEach(
/* doing something */
);