{"id":15042968,"url":"https://github.com/pivovarit/throwing-function","last_synced_at":"2025-05-15T02:10:18.463Z","repository":{"id":2605566,"uuid":"46967967","full_name":"pivovarit/throwing-function","owner":"pivovarit","description":"Checked Exceptions-enabled Java 8+ functional interfaces + adapters","archived":false,"fork":false,"pushed_at":"2025-05-12T05:54:55.000Z","size":392,"stargazers_count":383,"open_issues_count":6,"forks_count":60,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-12T06:37:55.922Z","etag":null,"topics":["exception-handling","functional-programming","hacktoberfest","java-8"],"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/pivovarit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["pivovarit"]}},"created_at":"2015-11-27T08:16:59.000Z","updated_at":"2025-05-12T05:54:16.000Z","dependencies_parsed_at":"2024-12-13T06:04:22.317Z","dependency_job_id":"afa4b35e-0714-4e72-aa5b-96a28dd9a21f","html_url":"https://github.com/pivovarit/throwing-function","commit_stats":{"total_commits":312,"total_committers":16,"mean_commits":19.5,"dds":0.5865384615384616,"last_synced_commit":"35bfc5c4c47327bb5e42fb019a893dec260fa610"},"previous_names":["touk/throwingfunction","pivovarit/throwingfunction"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pivovarit%2Fthrowing-function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pivovarit%2Fthrowing-function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pivovarit%2Fthrowing-function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pivovarit%2Fthrowing-function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pivovarit","download_url":"https://codeload.github.com/pivovarit/throwing-function/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254259387,"owners_count":22040821,"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":["exception-handling","functional-programming","hacktoberfest","java-8"],"created_at":"2024-09-24T20:48:23.814Z","updated_at":"2025-05-15T02:10:13.454Z","avatar_url":"https://github.com/pivovarit.png","language":"Java","funding_links":["https://github.com/sponsors/pivovarit"],"categories":[],"sub_categories":[],"readme":"# Checked-Exceptions-enabled Java 8+ Functional Interfaces\n\n[![Build against JDKs](https://github.com/pivovarit/throwing-function/actions/workflows/ci.yml/badge.svg)](https://github.com/pivovarit/throwing-function/actions/workflows/ci.yml)\n[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)\n![Maven Central Version](https://img.shields.io/maven-central/v/com.pivovarit/throwing-function)\n[![libs.tech recommends](https://libs.tech/project/46967967/badge.svg)](https://libs.tech/project/46967967/throwing-function)\n\n\n[![Stargazers over time](https://starchart.cc/pivovarit/throwing-function.svg?variant=adaptive)](https://starchart.cc/pivovarit/throwing-function)\n\n## Overview\n\nJava’s standard `java.util.function` interfaces are not compatible with checked exceptions. This leads to verbose and cluttered code, requiring manual try-catch blocks for exception handling, which makes one-liners like this:\n\n```\npath -\u003e new URI(path)\n```\nbecome as verbose as:\n\n```\npath -\u003e {\n    try {\n        return new URI(path);\n    } catch (URISyntaxException e) {\n        throw new RuntimeException(e);\n    }\n}\n```    \n\nThis library introduces checked-exception-enabled functional interfaces, like `ThrowingFunction`, allowing cleaner, more concise code. You can now handle exceptions in functional pipelines without sacrificing readability:\n\n    ThrowingFunction\u003cString, URI, URISyntaxException\u003e toUri = URI::new;\n\nUsing the `ThrowingFunction#unchecked` adapter, this can be seamlessly integrated into standard streams:\n\n    ...stream()\n      .map(unchecked(URI::new)) // static import of ThrowingFunction#unchecked\n      .forEach(System.out::println);\n\nThis eliminates the need for bulky try-catch blocks within stream operations:\n\n     ...stream().map(path -\u003e {\n         try {\n             return new URI(path);\n         } catch (URISyntaxException e) {\n             throw new RuntimeException(e);\n         }}).forEach(System.out::println);\n\n### Key Features\n\n- Functional Interfaces: Supports various functional types with checked exceptions.\n- Adapters: Provides utility methods to convert `Throwing*` types into standard Java functional interfaces.\n- Lightweight: No external dependencies, implemented using core Java libraries.\n\n### Core API\n\n#### Functional Interfaces\n\n- [ThrowingFunction](https://github.com/pivovarit/throwing-function/blob/master/src/main/java/com/pivovarit/function/ThrowingFunction.java)\n- [ThrowingIntFunction](https://github.com/pivovarit/throwing-function/blob/master/src/main/java/com/pivovarit/function/ThrowingIntFunction.java)\n- [ThrowingToLongFunction](https://github.com/pivovarit/throwing-function/blob/master/src/main/java/com/pivovarit/function/ThrowingToLongFunction.java)\n- [ThrowingBiConsumer](https://github.com/pivovarit/throwing-function/blob/master/src/main/java/com/pivovarit/function/ThrowingBiConsumer.java)\n- [ThrowingBiFunction](https://github.com/pivovarit/throwing-function/blob/master/src/main/java/com/pivovarit/function/ThrowingBiFunction.java)\n- [ThrowingBiPredicate](https://github.com/pivovarit/throwing-function/blob/master/src/main/java/com/pivovarit/function/ThrowingBiPredicate.java)\n- [ThrowingBinaryOperator](https://github.com/pivovarit/throwing-function/blob/master/src/main/java/com/pivovarit/function/ThrowingBinaryOperator.java)\n- [ThrowingConsumer](https://github.com/pivovarit/throwing-function/blob/master/src/main/java/com/pivovarit/function/ThrowingConsumer.java)\n- [ThrowingPredicate](https://github.com/pivovarit/throwing-function/blob/master/src/main/java/com/pivovarit/function/ThrowingPredicate.java)\n- [ThrowingRunnable](https://github.com/pivovarit/throwing-function/blob/master/src/main/java/com/pivovarit/function/ThrowingRunnable.java)\n- [ThrowingSupplier](https://github.com/pivovarit/throwing-function/blob/master/src/main/java/com/pivovarit/function/ThrowingSupplier.java)\n- [ThrowingUnaryOperator](https://github.com/pivovarit/throwing-function/blob/master/src/main/java/com/pivovarit/function/ThrowingUnaryOperator.java)\n\n\n#### Adapters\n+ `static Function\u003cT, R\u003e unchecked(ThrowingFunction\u003c\u003e f) {...}`\n\nTransforms a `ThrowingFunction` instance into a standard `java.util.function.Function` by wrapping checked exceptions in a `RuntimeException` and rethrowing them. \n\n+ `static Function\u003cT, Optional\u003cR\u003e\u003e lifted() {...}`\n\nTransforms a `ThrowingFunction` instance into a regular `Function` returning result wrapped in an `Optional` instance. \n\n+ `default ThrowingFunction\u003cT, Void, E\u003e asFunction() {...}`\n\nReturns `Throwing(Predicate|Supplier|Consumer`) instance as a new `ThrowingFunction` instance.\n\n### Maven Central\n\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.pivovarit\u003c/groupId\u003e\n        \u003cartifactId\u003ethrowing-function\u003c/artifactId\u003e\n        \u003cversion\u003e1.6.1\u003c/version\u003e\n    \u003c/dependency\u003e\n    \n##### Gradle\n\n    compile 'com.pivovarit:throwing-function:1.6.1'\n\n### Dependencies\n\nNone - the library is implemented using core Java libraries.\n\n## Version history\n\n## [1.6.1 (25-09-2024)](https://github.com/pivovarit/throwing-function/releases/tag/1.6.1)\n\n* Explicit module configuration via a multi-release jar\n* Improved Javadoc \n\n### [1.6.0 (24-09-2024)](https://github.com/pivovarit/throwing-function/releases/tag/1.6.0)\n\n* Added `Automatic-Module-Name` to MANIFEST\n\n### [1.5.1 (06-05-2020)](https://github.com/pivovarit/throwing-function/releases/tag/1.5.1)\n\n* Fixed visibility issues with `ThrowingIntFunction`\n\n### [1.5.0 (26-01-2019)](https://github.com/pivovarit/throwing-function/releases/tag/1.5.0)\n\n* Introduced proper [Semantic Versioning](https://semver.org)\n* Introduced `ThrowingIntFunction`\n* Moved interfaces to `com.pivovarit.function`\n* Removed controversial `unwrap()` functionality\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpivovarit%2Fthrowing-function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpivovarit%2Fthrowing-function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpivovarit%2Fthrowing-function/lists"}