{"id":13458757,"url":"https://github.com/amaembo/streamex","last_synced_at":"2025-05-14T08:05:15.964Z","repository":{"id":30189446,"uuid":"33740196","full_name":"amaembo/streamex","owner":"amaembo","description":"Enhancing Java Stream API","archived":false,"fork":false,"pushed_at":"2025-03-27T15:08:55.000Z","size":5326,"stargazers_count":2244,"open_issues_count":19,"forks_count":256,"subscribers_count":78,"default_branch":"master","last_synced_at":"2025-05-14T08:04:24.288Z","etag":null,"topics":["collections","java","java8","streams-api"],"latest_commit_sha":null,"homepage":"","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/amaembo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2015-04-10T17:02:32.000Z","updated_at":"2025-05-08T00:41:44.000Z","dependencies_parsed_at":"2022-07-11T21:01:53.636Z","dependency_job_id":"6d85fd0c-1ff3-4bf3-a6d7-678c4cc9d955","html_url":"https://github.com/amaembo/streamex","commit_stats":{"total_commits":1325,"total_committers":29,"mean_commits":"45.689655172413794","dds":0.2128301886792453,"last_synced_commit":"ce4bb3f288d78c8e7e10d38ed08d56c0885b8479"},"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amaembo%2Fstreamex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amaembo%2Fstreamex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amaembo%2Fstreamex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amaembo%2Fstreamex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amaembo","download_url":"https://codeload.github.com/amaembo/streamex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101588,"owners_count":22014907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["collections","java","java8","streams-api"],"created_at":"2024-07-31T09:00:56.859Z","updated_at":"2025-05-14T08:05:15.942Z","avatar_url":"https://github.com/amaembo.png","language":"Java","funding_links":[],"categories":["Java","Projects","\u003e 1k ★","项目","Streams libraries"],"sub_categories":["Functional Programming","函数式编程"],"readme":"# StreamEx 0.8.3\nEnhancing the Java Stream API.\n\n[![Maven Central](https://img.shields.io/maven-central/v/one.util/streamex.svg)](https://maven-badges.herokuapp.com/maven-central/one.util/streamex/)\n[![Javadocs](https://www.javadoc.io/badge/one.util/streamex.svg)](https://www.javadoc.io/doc/one.util/streamex)\n[![Build Status](https://github.com/amaembo/streamex/actions/workflows/test.yml/badge.svg)](https://github.com/amaembo/streamex/actions/workflows/test.yml)\n[![Coverage Status](https://coveralls.io/repos/amaembo/streamex/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/amaembo/streamex?branch=master)\n\nThis library defines four classes: `StreamEx`, `IntStreamEx`, `LongStreamEx`, `DoubleStreamEx`\nthat are fully compatible with the Java 8 stream classes and provide many useful additional methods.\nAlso, the `EntryStream` class is provided which represents a stream of map entries and provides\nadditional functionality for this case. Finally, there are some useful new collectors defined in `MoreCollectors`\nclass as well as the primitive collectors concept.\n\nFull API documentation is available [here](http://amaembo.github.io/streamex/javadoc/).\n\nTake a look at the [Cheatsheet](wiki/CHEATSHEET.md) for brief introduction to StreamEx!\n\nBefore updating StreamEx check the [migration notes](wiki/MIGRATION.md) and the full list of [changes](wiki/CHANGES.md).\n\nStreamEx main points are the following:\n\n* Shorter and convenient ways to do common tasks.\n* Better interoperability with older code.\n* 100% compatibility with the original JDK streams.\n* Friendliness for parallel processing: any new feature takes advantage of parallel streams as much as possible.\n* Performance and minimal overhead. Whenever StreamEx allows solving a task using less code compared to the standard JDK\nStream API, it should not be significantly slower than the standard way (and sometimes it's even faster).\n\n### Examples\n\nCollector shortcut methods (toList, toSet, groupingBy, joining, etc.)\n```java\nList\u003cString\u003e userNames = StreamEx.of(users).map(User::getName).toList();\nMap\u003cRole, List\u003cUser\u003e\u003e role2users = StreamEx.of(users).groupingBy(User::getRole);\nStreamEx.of(1,2,3).joining(\"; \"); // \"1; 2; 3\"\n```\n\nSelecting stream elements of a specific type\n```java\npublic List\u003cElement\u003e elementsOf(NodeList nodeList) {\n    return IntStreamEx.range(nodeList.getLength())\n      .mapToObj(nodeList::item).select(Element.class).toList();\n}\n```\n\nAdding elements to a stream\n```java\npublic List\u003cString\u003e getDropDownOptions() {\n    return StreamEx.of(users).map(User::getName).prepend(\"(none)\").toList();\n}\n\npublic int[] addValue(int[] arr, int value) {\n    return IntStreamEx.of(arr).append(value).toArray();\n}\n```\n\nRemoving unwanted elements and using a stream as an Iterable:\n```java\npublic void copyNonEmptyLines(Reader reader, Writer writer) throws IOException {\n    for(String line : StreamEx.ofLines(reader).remove(String::isEmpty)) {\n        writer.write(line);\n        writer.write(System.lineSeparator());\n    }\n}\n```\n\nSelecting map keys by value predicate:\n```java\nMap\u003cString, Role\u003e nameToRole;\n\npublic Set\u003cString\u003e getEnabledRoleNames() {\n    return StreamEx.ofKeys(nameToRole, Role::isEnabled).toSet();\n}\n```\n\nOperating on key-value pairs:\n```java\npublic Map\u003cString, List\u003cString\u003e\u003e invert(Map\u003cString, List\u003cString\u003e\u003e map) {\n    return EntryStream.of(map).flatMapValues(List::stream).invert().grouping();\n}\n\npublic Map\u003cString, String\u003e stringMap(Map\u003cObject, Object\u003e map) {\n    return EntryStream.of(map).mapKeys(String::valueOf)\n        .mapValues(String::valueOf).toMap();\n}\n\nMap\u003cString, Group\u003e nameToGroup;\n\npublic Map\u003cString, List\u003cUser\u003e\u003e getGroupMembers(Collection\u003cString\u003e groupNames) {\n    return StreamEx.of(groupNames).mapToEntry(nameToGroup::get)\n        .nonNullValues().mapValues(Group::getMembers).toMap();\n}\n```\n\nPairwise differences:\n```java\nDoubleStreamEx.of(input).pairMap((a, b) -\u003e b-a).toArray();\n```\n\nSupport for byte/char/short/float types:\n```java\nshort[] multiply(short[] src, short multiplier) {\n    return IntStreamEx.of(src).map(x -\u003e x*multiplier).toShortArray(); \n}\n```\n\nDefine a custom lazy intermediate operation recursively:\n```java\nstatic \u003cT\u003e StreamEx\u003cT\u003e scanLeft(StreamEx\u003cT\u003e input, BinaryOperator\u003cT\u003e operator) {\n        return input.headTail((head, tail) -\u003e scanLeft(tail.mapFirst(cur -\u003e operator.apply(head, cur)), operator)\n                .prepend(head));\n}\n```\n\nAnd more!\n\n### License\n\nThis project is licensed under [Apache License, version 2.0](https://www.apache.org/licenses/LICENSE-2.0)\n\n### Installation\n\nReleases are available in [Maven Central](https://repo1.maven.org/maven2/one/util/streamex/)\n\nBefore updating StreamEx check the [migration notes](wiki/MIGRATION.md) and the full list of [changes](wiki/CHANGES.md).\n\n#### Maven\n\nAdd this snippet to your project's pom.xml `dependencies` section:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eone.util\u003c/groupId\u003e\n  \u003cartifactId\u003estreamex\u003c/artifactId\u003e\n  \u003cversion\u003e0.8.3\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n#### Gradle \n\nAdd this snippet to your project's build.gradle `dependencies` section:\n\n```groovy\nimplementation 'one.util:streamex:0.8.3'\n```\n\nPull requests are welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famaembo%2Fstreamex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famaembo%2Fstreamex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famaembo%2Fstreamex/lists"}