Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pivovarit/more-gatherers

Missing Stream API functionality you always longed for - provided via Stream API Gatherers
https://github.com/pivovarit/more-gatherers

gatherers hacktoberfest java stream

Last synced: about 2 months ago
JSON representation

Missing Stream API functionality you always longed for - provided via Stream API Gatherers

Awesome Lists containing this project

README

        

# more-gatherers

Missing Stream API functionality you always longed for - provided via `Gatherers`

[![build](https://github.com/pivovarit/more-gatherers/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/pivovarit/more-gatherers/actions/workflows/build.yml)
[![pitest](https://github.com/pivovarit/more-gatherers/actions/workflows/pitest.yml/badge.svg?branch=main)](https://pivovarit.github.io/more-gatherers)
![Maven Central Version](https://img.shields.io/maven-central/v/com.pivovarit/more-gatherers)

[![Stargazers over time](https://starchart.cc/pivovarit/more-gatherers.svg?variant=adaptive)](https://starchart.cc/pivovarit/more-gatherers)

## Project is under intense development and will be released alongside Java 24, when Stream Gatherers go GA (hopefully)

### Overview

Java's Stream API is a powerful tool for processing collections of data. However, it lacks some functionality that could make it even more powerful. This library aims to fill that gap by providing a set of `Gatherers` that can be used to collect data from a stream more flexibly.

Whenever possible, the library follows Project Reactor's naming conventions.

Provided `Gatherers`:
- `MoreGatherers.last(int)`
- takes last `n` elements from the stream
- `MoreGatherers.sampling(int)`
- takes every `n`-th element from the stream
- `MoreGatherers.zip(Iterator)`
- zips `Stream` elements with elements from the provided `Iterator`
- `MoreGatherers.zip(Iterator, BiFunction)`
- zips `Stream` elements with elements from the provided `Iterator` using a custom zipper function
- `MoreGatherers.zip(Stream)`
- zips `Stream` elements with elements from the provided `Stream`
- `MoreGatherers.zip(Stream, BiFunction)`
- zips `Stream` elements with elements from the provided `Stream` using a custom zipper function
- `MoreGatherers.zipWithIterable(Iterable)`
- zips `Stream` elements with elements from the provided `Iterable`
- `MoreGatherers.zipWithIterable(Iterable, BiFunction)`
- zips elements with elements from the provided `Iterable` using a custom zipper function
- `MoreGatherers.zipWithIndex()`
- zips `Stream` elements with their index
- `MoreGatherers.zipWithIndex(BiFunction)`
- zips `Stream` elements with their index using a custom zipper function
- `MoreGatherers.distinctBy(Function)`
- takes distinct elements based on a key extractor function
- `MoreGatherers.distinctByKeepLast(Function)`
- takes distinct elements based on a key extractor function, keeping the last occurrence
- `MoreGatherers.distinctUntilChanged()`
- takes elements until a change is detected
- `MoreGatherers.distinctUntilChanged(Function)`
- takes elements until a change is detected based on a key extractor function
- `MoreGatherers.windowSliding(int, int)`
- creates a sliding window of a fixed size with a fixed step, extends `Gatherers.windowSliding(int)` by adding a step parameter
- `MoreGatherers.byIndex(BiPredicate)`
- filters elements based on their index and value

### Philosophy

The primary goal of this library is to complement the existing Stream API by providing functionality that's currently missing without duplicating features already available. While it is technically possible to create numerous custom Gatherers, this library focuses on offering only those that cannot be easily achieved using standard Stream API operations.

The library is designed to be as lightweight as possible, with no external dependencies. It's implemented using core Java libraries and follows the same conventions as the standard Stream API, drawing inspiration from Project Reactor's method names.