If you take a look at JDK-22, you will find a very interesting thing called 461: Stream Gatherers (Preview). Those Gatherers are a way to enhance the Stream API, which has existed in the
JDK since 2014 (JDK 8). The collectors have been enhanced over time (you can look up the differences via Javaalmanac check for Collectors). The provided collectors in the JDK already cover a lot of things, but sometimes there are situations where it’s not enough or not flexible enough or would produce code that is hard to read (more accurate, hard to understand). The first thought could be to request an enhancement of the Collectors in the JDK itself, but that would mean adding more methods on the collectors, which already have 44 methods (if I have counted correctly). Apart from having a problem that is so specific, it’s worth adding that to the JDK itself. So, it might be a better solution to give the users a way to enhance the Stream API based on their own needs. That is also the summary of the JEP 461:
Enhance the Stream API to support custom intermediate operations.
This will allow stream pipelines to transform data in ways that are not easily achievable with the existing built-in intermediate operations. This is a preview API.