Suppose I have this bit of code:
Map<Consumer, Item> map = myStream.parallel()
.filter(Objects::nonNull)
.collect(Collectors.toConcurrentMap(e->e,
e->e, mergeFunction));
What I want to do is call a method on each object of the stream after collecting is done.
For example,
item.setDate(item.getOneDate());
Before the code done sequentially looped through items, put into a map, and at the very end called a bit of the code like the one above, setting a 'date'.
while(iterator.hasNext()) {
Item blah = iterator.next();
....
// code for putting into map
...
blah.setDate(blah.getOneDate());
}
Not sure how to do this with Java 8 streams. forEach
? peek
?