Better Java Streams with Gatherers - JEP Cafe #23
José Paumard on November 26, 2024This JEP Café explains what Gatherers represent, an API introduced in JDK 24 to supplement intermediary operations for the Java 8 Stream API. It goes through all you need to know to use this API efficiently, in a step-by-step approach, with many examples, from the simplest you can imagine, to more complex ones. It gives you in-depth details of the intermediate and terminal operations of the Stream API, and how they work internally, to better understand how Gatherers are working, and why this API has been designed in that way. You will learn about using flat-mapping to validate the elements of your stream, how you can use mapMulti() to avoid creating stream objects, how some stream operations have to manage an internal mutable state to work, how they can interrupt a stream, and how parallelization works under the hood. All this can be used in the creation of your custom gatherers.
Make sure to check the show-notes!