{"id":20401247,"url":"https://github.com/rubenjgarcia/commons-functional","last_synced_at":"2026-05-26T23:04:02.691Z","repository":{"id":57731253,"uuid":"70259474","full_name":"rubenjgarcia/commons-functional","owner":"rubenjgarcia","description":"A collection of Functional helpers for Java 8","archived":false,"fork":false,"pushed_at":"2017-03-24T11:56:44.000Z","size":34,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"dev","last_synced_at":"2025-03-05T01:42:17.147Z","etag":null,"topics":["functional","functional-programming","java-8","tuples"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubenjgarcia.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}},"created_at":"2016-10-07T15:31:34.000Z","updated_at":"2019-02-11T18:49:36.000Z","dependencies_parsed_at":"2022-09-26T22:10:19.450Z","dependency_job_id":null,"html_url":"https://github.com/rubenjgarcia/commons-functional","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/rubenjgarcia/commons-functional","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenjgarcia%2Fcommons-functional","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenjgarcia%2Fcommons-functional/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenjgarcia%2Fcommons-functional/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenjgarcia%2Fcommons-functional/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubenjgarcia","download_url":"https://codeload.github.com/rubenjgarcia/commons-functional/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenjgarcia%2Fcommons-functional/sbom","scorecard":{"id":788635,"data":{"date":"2025-08-11","repo":{"name":"github.com/rubenjgarcia/commons-functional","commit":"bc5ab715ebbdd7638420f54eb36d4427512f95c3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/11 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'dev'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 7 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T06:48:48.279Z","repository_id":57731253,"created_at":"2025-08-23T06:48:48.279Z","updated_at":"2025-08-23T06:48:48.279Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33542350,"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":["functional","functional-programming","java-8","tuples"],"created_at":"2024-11-15T04:48:43.054Z","updated_at":"2026-05-26T23:04:02.676Z","avatar_url":"https://github.com/rubenjgarcia.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Commons functional\n\nA collection of Functional helpers\n\n## Tuples\n\nFrom 1 to 10 fields\n\n```\nimport es.rubenjgarcia.commons.functional.tuple.*;\nimport static es.rubenjgarcia.commons.functional.tuple.Tuple.tuple;\n\nTuple2 t2 = tuple(\"1\", \"2\");\nt2.toString(); // (1, 2)\nt2.equals(tuple(\"1\", \"2\")); // true\n```\n\n## Stream Utils\n\n### zip\n\nReturns a list of [Tuple2](src/main/java/es/rubenjgarcia/commons/functional/tuple/Tuple2.java) formed from two streams by combining corresponding elements in pairs. If one of the two collections is longer than the other, its remaining elements are ignored.\n\n```\nimport static es.rubenjgarcia.commons.functional.StreamUtils.zip;\n\nList\u003cInteger\u003e ints = Arrays.asList(1, 2, 3);\nList\u003cString\u003e strings = Arrays.asList(\"a\", \"b\", \"c\");\n\nList\u003cTuple2\u003cInteger, String\u003e\u003e tuples = zip(ints.stream(), strings.stream()).collect(Collectors.toList());\ntuples.toString(); // [(1, a), (2, b), (3, c)]\n```\n\n### zipWithIndex\n\n```\nimport static es.rubenjgarcia.commons.functional.StreamUtils.zipWithIndex;\n\nList\u003cString\u003e strings = Arrays.asList(\"1\", \"2\", \"3\");\nList\u003cTuple2\u003cLong, String\u003e\u003e tuples = zipWithIndex(strings.stream()).collect(Collectors.toList());\n```\n\n### unzip\n\nConverts a collection of [Tuple2](src/main/java/es/rubenjgarcia/commons/functional/tuple/Tuple2.java) into a [Tuple2](src/main/java/es/rubenjgarcia/commons/functional/tuple/Tuple2.java) of stream of the first and second half of each pair\n\n```\nimport es.rubenjgarcia.commons.functional.tuple.*;\nimport static es.rubenjgarcia.commons.functional.StreamUtils.unzip;\n\nTuple2\u003cStream\u003cInteger\u003e, Stream\u003cString\u003e\u003e tupleStream = unzip(tuples);\nList\u003cInteger\u003e ints = tupleStream._1.collect(Collectors.toList());\nList\u003cString\u003e strings = tupleStream._2.collect(Collectors.toList());\n```\n\n## Functional Filters\n\n### anyOf\n\nReturn if the value matches any predicate\n\n```\nimport static es.rubenjgarcia.commons.functional.FunctionalFilters.anyOf;\n\nPredicate\u003cInteger\u003e p = anyOf(n -\u003e n == 1, n -\u003e n == 2);\np.test(1); // true\np.test(3); // false\n```\n\n### noneOf\n\nReturn if the value doesn't match any of the predicates\n\n```\nimport static es.rubenjgarcia.commons.functional.FunctionalFilters.noneOf;\n\nPredicate\u003cInteger\u003e p = noneOf(n -\u003e n == 1, n -\u003e n == 2);\np.test(1); // false\np.test(3); // true\n```\n\n### allOf\n\nReturn if the value matches all the predicates\n\n```\nimport static es.rubenjgarcia.commons.functional.FunctionalFilters.allOf;\n\nPredicate\u003cInteger\u003e p = allOf(n -\u003e n \u003e 1, n -\u003e n \u003c 3);\np.test(1); // false\np.test(2); // true\n```\n\n### findFirst\n\nFind the first element that matchs the predicate\n\n```\nimport static es.rubenjgarcia.commons.functional.FunctionalFilters.findFirst;\n\nOptional\u003cInteger\u003e found = findFirst(Stream.of(1, 2), n -\u003e n == 1);\nfound.isPresent(); // true\nfound.get(); 1\n```\n\n### findLast\n\nFinds the last element that matchs the predicate\n\n```\nimport static es.rubenjgarcia.commons.functional.FunctionalFilters.findLast;\n\nOptional\u003cInteger\u003e last = findLast(Stream.of(1, 2, 3), p -\u003e p \u003e 1 \u0026\u0026 p \u003c= 2);\nlast.isPresent(); // true\nlast.get(); // 2\n```\n\n### findFirstNotMatch\n\nFinds first element that doesn't match the predicate\n\n```\nimport static es.rubenjgarcia.commons.functional.FunctionalFilters.findFirstNotMatch;\n\nOptional\u003cInteger\u003e found = findFirstNotMatch(Stream.of(1, 2), n -\u003e n == 1);\nfound.isPresent(); // true\nfound.get(); // 2\n```\n\n## FlowStream\n\n### mapIf\n\nApply a map function to the element of a stream if the element matches the predicate\n\n```\nimport static es.rubenjgarcia.commons.functional.FlowStream.mapIf;\n\nList\u003cInteger\u003e list = Arrays.asList(1, 1, 1, 1);\nList\u003cObject\u003e result = mapIf(list::stream, i -\u003e i == 1, i -\u003e \"A\")\n        .collect(Collectors.toList()); // [A, A, A, A]\n```\n\n```\nList\u003cInteger\u003e list = Arrays.asList(1, 2, 2, 1);\nList\u003cObject\u003e result = mapIf(list::stream, i -\u003e i == 1, i -\u003e \"A\")\n        .collect(Collectors.toList()); // [A, 2, 2, A]\n```\n\n### elseIfMap\n\nApply a map function to the element of a stream if the element matches the predicate after a mapIf code\n\n```\nimport static es.rubenjgarcia.commons.functional.FlowStream.mapIf;\n\nList\u003cInteger\u003e list = Arrays.asList(1, 2, 3, 1);\nList\u003cObject\u003e result = mapIf(list::stream, i -\u003e i == 1, i -\u003e \"A\")\n        .elseIfMap(i -\u003e i == 2, i -\u003e \"B\")\n        .collect(Collectors.toList()); // [A, B, 3, A]\n```\n\n```\nimport static es.rubenjgarcia.commons.functional.FlowStream.mapIf;\n\nList\u003cInteger\u003e list = Arrays.asList(1, 2, 3, 1);\nList\u003cObject\u003e result = mapIf(list::stream, i -\u003e i == 1, i -\u003e \"A\")\n        .elseIfMap(i -\u003e i == 2, i -\u003e \"B\")\n        .elseIfMap(i -\u003e i == 3, i -\u003e \"C\")\n        .collect(Collectors.toList()); // [A, B, C, A]\n```\n\n### elseMap\n\nApply a map function to the elements of a stream that don't match any of the other if or elseif predicates\n\n```\nimport static es.rubenjgarcia.commons.functional.FlowStream.mapIf;\n\nList\u003cInteger\u003e list = Arrays.asList(1, 2, 3, 1);\nList\u003cObject\u003e result = mapIf(list::stream, i -\u003e i == 1, i -\u003e \"A\")\n        .elseIfMap(i -\u003e i == 2, i -\u003e \"B\")\n        .elseMap(i -\u003e \"C\")\n        .collect(Collectors.toList()); // [A, B, C, A]\n```\n\n```\nimport static es.rubenjgarcia.commons.functional.FlowStream.mapIf;\n\nList\u003cInteger\u003e list = Arrays.asList(1, 2, 3, 1);\nList\u003cObject\u003e result = mapIf(list::stream, i -\u003e i == 1, i -\u003e \"A\")\n        .elseMap(i -\u003e \"C\")\n        .collect(Collectors.toList()); // [A, C, C, A]\n```\n\n### mapIfAny\n\nApply a map function to all the elements of the stream if any of them match the predicate\n\n```\nimport static es.rubenjgarcia.commons.functional.FlowStream.mapIfAny;\n\nList\u003cInteger\u003e list = Arrays.asList(1, 2, 2, 1);\nList\u003cObject\u003e result = mapIfAny(list::stream, i -\u003e i == 1, i -\u003e \"A\")\n        .collect(Collectors.toList()); // [A, A, A, A]\n```\n\n### elseIfAnyMap\n\nApply a map function to all the elements of the stream if any of them match the predicate and don't match the other predicates\n\n```\nimport static es.rubenjgarcia.commons.functional.FlowStream.mapIfAny;\n\nList\u003cInteger\u003e list = Arrays.asList(1, 1, 1, 1);\nList\u003cObject\u003e result = mapIfAny(list::stream, i -\u003e i == 2, i -\u003e \"A\")\n        .elseIfAnyMap(i -\u003e i == 1, i -\u003e \"B\")\n        .collect(Collectors.toList()); // [B, B, B, B]\n```\n\n```\nimport static es.rubenjgarcia.commons.functional.FlowStream.mapIfAny;\n\nList\u003cInteger\u003e list = Arrays.asList(1, 2, 3, 1);\nList\u003cObject\u003e result = mapIfAny(list::stream, i -\u003e i == 2, i -\u003e \"A\")\n        .elseIfAnyMap(i -\u003e i == 4, i -\u003e \"B\")\n        .elseIfAnyMap(i -\u003e i == 1, i -\u003e \"C\")\n        .collect(Collectors.toList()); // [C, C, C, C]\n```\n\nYou can combine any of the flows\n\n```\nimport static es.rubenjgarcia.commons.functional.FlowStream.mapIf;\n\nList\u003cInteger\u003e list = Arrays.asList(1, 2, 1, 1);\nList\u003cObject\u003e result = mapIf(list::stream, i -\u003e i == 2, i -\u003e \"A\")\n        .elseIfAnyMap(i -\u003e i == 1, i -\u003e \"B\")\n        .elseMap(i -\u003e \"C\")\n        .collect(Collectors.toList()); // [B, A, B, B]\n```\n\n## Exceptions \n\nYou can use `rethrowFunction`, `rethrowBiFunction`, `rethrowConsumer`, `rethrowBiConsumer`, `rethrowPredicate`, `rethrowBiPredicate` or `rethrowSupplier` to deal with [Function](https://docs.oracle.com/javase/8/docs/api/java/util/function/Function.html), [BiFunction](https://docs.oracle.com/javase/8/docs/api/java/util/function/BiFunction.html), [Consumer](https://docs.oracle.com/javase/8/docs/api/java/util/function/Consumer.html), [BiConsumer](https://docs.oracle.com/javase/8/docs/api/java/util/function/BiConsumer.html), [Predicate](https://docs.oracle.com/javase/8/docs/api/java/util/function/Predicate.html), [BiPredicate](https://docs.oracle.com/javase/8/docs/api/java/util/function/BiPredicate.html) or [Supplier](https://docs.oracle.com/javase/8/docs/api/java/util/function/Supplier.html) that throws any checked [Exception](https://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html) \n\n```\nimport static es.rubenjgarcia.commons.functional.FunctionalExceptions.rethrowFunction;\n\nStream.of(\"a\", \"b\").map(rethrowFunction(s -\u003e new String(s.getBytes(), \"Foo\")));\n```\n\n```\nimport static es.rubenjgarcia.commons.functional.FunctionalExceptions.rethrowBiFunction;\n\nMap\u003cString, String\u003e map = new HashMap\u003c\u003e();\nmap.put(\"a\", \"b\");\nmap.replaceAll(rethrowBiFunction((k, v) -\u003e new String(k.getBytes(), \"Foo\")))\n```\n\n```\nimport static es.rubenjgarcia.commons.functional.FunctionalExceptions.rethrowConsumer;\n\nStream.of(\"a\", \"b\").forEach(rethrowConsumer(s -\u003e new String(s.getBytes(), \"Foo\")));\n```\n\n```\nimport static es.rubenjgarcia.commons.functional.FunctionalExceptions.rethrowBiConsumer;\n\nMap\u003cString, String\u003e map = new HashMap\u003c\u003e();\nmap.put(\"a\", \"b\");\nmap.forEach(rethrowBiConsumer((k, v) -\u003e new String(k.getBytes(), \"Foo\")));\n```\n\n```\nimport static es.rubenjgarcia.commons.functional.FunctionalExceptions.rethrowPredicate;\n\nStream.of(\"a\", \"b\").filter(rethrowPredicate(s -\u003e new String(s.getBytes(), \"Foo\") == null));\n```\n\n```\nimport static es.rubenjgarcia.commons.functional.FunctionalExceptions.rethrowBiPredicate;\n\nBiPredicate\u003cString, String\u003e predicate = rethrowBiPredicate((s, e) -\u003e new String(s.getBytes(), e).isEmpty());\npredicate.test(\"a\", \"Foo\");\n```\n\n```\nimport static es.rubenjgarcia.commons.functional.FunctionalExceptions.rethrowSupplier;\n\nrethrowPredicate(() -\u003e new String(s.getBytes(), \"Foo\"));\n```\n\n# Installation\n\nJust add to your pom.xml\n\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ees.rubenjgarcia\u003c/groupId\u003e\n    \u003cartifactId\u003ecommons-functional\u003c/artifactId\u003e\n    \u003cversion\u003e0.2.0\u003c/version\u003e\n\u003c/dependency\u003e\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenjgarcia%2Fcommons-functional","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubenjgarcia%2Fcommons-functional","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenjgarcia%2Fcommons-functional/lists"}