A library of useful Stream Gatherers (custom intermediate operations) for Java 22+.
TBD, once I start publishing snapshots to Maven Central.
(Example, TODO clean this up)
Removing consecutive duplicate elements:
Stream
.of("A", "A", "A", "B", "B", "C", "C", "D", "A", "B", "C")
.gather(Gatherers4j.dedupeConsecutive())
.toList();
// ["A", "B", "C", "D", "A", "B", "C"]
Limit the stream to the last
n elements:
Stream
.of("A", "B", "C", "D", "E", "F", "G")
.gather(Gatherers4j.last(3))
.toList();
// ["E", "F", "G"]
Guidance forthcoming.
Copyright © 2024 by Todd Ginsberg