Gatherers4J
Why Are We Here?
Since Streams were fist introduced in Java 8, there has been a way for us to write our own terminal operations with Collectors. However, there has not been a convenient way to write our own intermediate operations. Also, there are a lot of intermediate operations that seem like they would be good additions ot the JDK, but adding all of them to the Stream API would make it more difficult to learn and maintain.
Enter Gatherers! Finally, we have the ability to plug our own intermediate operations into Java Streams, so we can make life easier for ourselves, or use that sequence operation from another language that we miss in Java.
This library aims to provide a comprehensive and useful set of Gatherers (intermediate operations).
Shortcuts
Getting Started - The quickstart guide will show you how to add Gatherers4j to your project.
Gatherers are organized into five categories for easier searching:
Sequence Operations - Reorder, combine, or manipulate the sequence of elements.
Filtering and Selection - Select or remove elements based on some criteria.
Grouping and Windowing - Collect elements into groups or windows.
Mathematical Operations - Perform calculations over the stream.
Validation and Constraints - Enforce conditions on the stream.
Features
A Single Tiny Dependency
Don’t you hate it when you find a library that meets your needs only to discover that it comes with a massive tree of mandatory dependencies that conflict with your project?
Gatherers4j has a single dependency. JSpecify annotations are used on all public methods and types so static type checkers can more easily check for nullability issues. It’s there to help you write better code. JSpecify is tiny (it is made up of only four annotations) and stable.
A Single Entrypoint
All the Gatherers in this library are exposed through a single class,
Gatherers4j
for
simplicity. The groups outlined above are only represented explicitly in the documentation.
Apache 2.0 License
This project is licensed under the business-friendly Apache 2.0 license, which means your legal team can probably stop sweating because Apache 2.0 is generally well-received in enterprise settings. You should definitely run this by your Actual Lawyers™ though!