Start United States USA — software Teeing, a Hidden Gem in The Java API

Teeing, a Hidden Gem in The Java API

192
0
TEILEN

We can replace our custom Collector with two simple Collector implementations, one aggregating price rows and the other summing the cart’s price.
Join the DZone community and get the full member experience. Last week, I described a use-case for a custom Stream Collector. I received a intriguing comment on Twitter: Hats off to you, Miguel! Your comment revealed a method I didn’t know! So I decided to investigate what is the teeing() method about. Returns a Collector that is a composite of two downstream collectors. Every element passed to the resulting collector is processed by both downstream collectors, then their results are merged using the specified merge function into the final result.

Continue reading...