{"id":20741125,"url":"https://github.com/robtimus/stream-utils","last_synced_at":"2026-05-26T20:05:45.080Z","repository":{"id":50676108,"uuid":"441926955","full_name":"robtimus/stream-utils","owner":"robtimus","description":"Provides utility classes for working with streams","archived":false,"fork":false,"pushed_at":"2026-04-18T12:07:19.000Z","size":576,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-18T12:31:26.803Z","etag":null,"topics":["collectors","java","stream","streams"],"latest_commit_sha":null,"homepage":"https://robtimus.github.io/stream-utils/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robtimus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-12-26T15:46:39.000Z","updated_at":"2026-04-18T12:07:23.000Z","dependencies_parsed_at":"2023-02-15T17:30:38.685Z","dependency_job_id":"31a304ee-3c25-404d-8bdd-6d84a78b88d3","html_url":"https://github.com/robtimus/stream-utils","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/robtimus/stream-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fstream-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fstream-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fstream-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fstream-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robtimus","download_url":"https://codeload.github.com/robtimus/stream-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fstream-utils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33536752,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"ssl_error","status_checked_at":"2026-05-26T15:22:15.568Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collectors","java","stream","streams"],"created_at":"2024-11-17T06:33:59.936Z","updated_at":"2026-05-26T20:05:45.062Z","avatar_url":"https://github.com/robtimus.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stream-utils\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.robtimus/stream-utils)](https://search.maven.org/artifact/com.github.robtimus/stream-utils)\n[![Build Status](https://github.com/robtimus/stream-utils/actions/workflows/build.yml/badge.svg)](https://github.com/robtimus/stream-utils/actions/workflows/build.yml)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=com.github.robtimus%3Astream-utils\u0026metric=alert_status)](https://sonarcloud.io/summary/overall?id=com.github.robtimus%3Astream-utils)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=com.github.robtimus%3Astream-utils\u0026metric=coverage)](https://sonarcloud.io/summary/overall?id=com.github.robtimus%3Astream-utils)\n\nProvides utility classes for working with streams.\n\n## Additional collectors\n\nClass [AdditionalCollectors](https://robtimus.github.io/stream-utils/apidocs/com/github/robtimus/stream/AdditionalCollectors.html) comes with the following utility methods:\n\n### sequentialOnly\n`sequentialOnly` is a collector factory method similar to `Collector.of`, but without the combiner. This can be used for collectors that cannot easily be combined, in cases where only sequential streams are used.\n\n### findSingle and findUnique\n`findSingle` is like `Stream.findAny`, but it throws an exception if the stream contains more than one element. It can be combined with `Optional.orElseThrow` to find exactly one element. Note that unlike `Stream.findAny`, the entire stream is processed.\n\n`findUnique` is like `findSingle` that allows multiple occurrences of the same element.\n\n### toMapWithSupplier\n`toMapWithSupplier` is like `Collectors.toMap`. However, unlike the version with only a key and value mapper, it allows you to provide a `Map` supplier. Unlike the version with a supplier there is no need to provide a merge function.\n\n### completionStages and completableFutures\n`completableFutures` can collect a stream of `CompletableFuture` elements into a combined `CompletableFuture`.\n`completionStages` is a more generic version of `completableFutures` that can collect a stream of `CompletionStage` elements. It can be used wherever `completableFutures` can be used.\n\n### partitioning\n`partitioning` splits the stream into several partitions. Each partition is collected separately, and these partition results are then collected. For example, the following can be used to create a `List\u003cList\u003cT\u003e\u003e`, where each inner list has at most 10 elements:\n\n```java\nstream.collect(partitioning(10, toList(), toList())\n```\n\nBecause it's hard to get predictable results for parallel streams, this collector will throw an exception when used to collect parallel streams.\n\n## Stream utils\n\nClass [StreamUtils](https://robtimus.github.io/stream-utils/apidocs/com/github/robtimus/stream/StreamUtils.html) comes with the following utility methods:\n\n### forEvery\n\n`forEvery` is like `AdditionalCollectors.partitioning` (see above), but runs an action for each partition result instead of collecting them. For example, to print 10 elements per line:\n\n```java\nforEvery(10, stream, joining(\", \"), System.out::println);\n```\n\nLike `AdditionalCollectors.partitioning`, this method will throw an exception when used to collect parallel streams.\n\n## FutureValue\n\nClass [FutureValue](https://robtimus.github.io/stream-utils/apidocs/com/github/robtimus/stream/FutureValue.html) provides utility methods to work with `CompletableFuture` in streams. Unlike `AdditionalCollectors.completableFutures`, methods in this class can be used to provide intermediate filtering and mapping. It also provides support for `Stream.collect` and `Stream.forEach` for `CompletableFuture`.\n\nTo use this class, use `Stream.map` in combination with `FutureValue.wrap`. Then `FutureValue.filter`, `FutureValue.map` and `FutureValue.flatMap` can be used any number of times before `Stream.collect` or `Stream.forEach` is called.\n\nFor example:\n\n```java\n// assume stream is an existing Stream\u003cCompletableFuture\u003cT\u003e\u003e\nCompletableFuture\u003cList\u003cT\u003e\u003e list = stream\n        .map(FutureValue::wrap)\n        .map(FutureValue.filter(Objects::nonNull))\n        .collect(FutureValue.collect(toList()));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobtimus%2Fstream-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobtimus%2Fstream-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobtimus%2Fstream-utils/lists"}