https://github.com/ashr123/exceptional-functions
A collection of functions that protect against unchecked Exceptions
https://github.com/ashr123/exceptional-functions
functional-programming java
Last synced: 2 months ago
JSON representation
A collection of functions that protect against unchecked Exceptions
- Host: GitHub
- URL: https://github.com/ashr123/exceptional-functions
- Owner: ashr123
- License: mit
- Created: 2022-03-02T21:29:59.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-09-22T06:53:15.000Z (6 months ago)
- Last Synced: 2025-09-22T08:43:05.558Z (6 months ago)
- Topics: functional-programming, java
- Language: Java
- Homepage:
- Size: 95.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# exceptional-functions
[](https://search.maven.org/search?q=g:%22io.github.ashr123%22%20AND%20a:%22exceptional-functions%22)
A collection of functions that protect against unchecked Exceptions.
Code example:
```java
import io.github.ashr123.exceptional.functions.ThrowingFunction;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
public class Example {
public static Stream exampleWithCasting() {
return Stream.of(
"https://www.google.com",
"https://www.ynet.co.il",
"https://www.stackoverflow.com"
)
.map(URI::create)
.map((ThrowingFunction) URI::toURL)
.map((ThrowingFunction) URL::openStream);
}
public static Stream exampleWithCastingAndWildcards() {
return Stream.of(
"https://www.google.com",
"https://www.ynet.co.il",
"https://www.stackoverflow.com"
)
.map(URI::create)
.map((ThrowingFunction) URI::toURL)
.map((ThrowingFunction) URL::openStream);
}
public static Stream exampleWithCallingUnchecked() {
return Stream.of(
"https://www.google.com",
"https://www.ynet.co.il",
"https://www.stackoverflow.com"
)
.map(URI::create)
.map(ThrowingFunction.unchecked(URI::toURL))
.map(ThrowingFunction.unchecked(URL::openStream));
}
public static R doSomeAction(URL url, ThrowingFunction action) throws T {
return action.applyThrows(url);
}
}
```