https://github.com/johnsonlee/lambda-support
Java 8 lambda support library
https://github.com/johnsonlee/lambda-support
Last synced: about 1 month ago
JSON representation
Java 8 lambda support library
- Host: GitHub
- URL: https://github.com/johnsonlee/lambda-support
- Owner: johnsonlee
- License: apache-2.0
- Created: 2020-03-04T04:06:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-23T08:32:17.000Z (about 6 years ago)
- Last Synced: 2025-03-22T05:27:13.469Z (about 1 year ago)
- Language: Java
- Homepage:
- Size: 71.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Lambda Support Library
This library is used to improve programming experience with Java 8 lambda expression, especially using lambda with exception handling.
The following example shows using lambda with `try-catch` block:
```java
public void cat(Collection files) {
files.stream().map(file -> {
try {
return Files.readString(file.toPath());
} catch (IOException e) {
return "";
}
}).forEach(System.out::println);
}
```
As we can see, the readability of code getting worse when using `try-catch` in lambda expression, this library is trying to solve this problem with small changes:
```java
public void cat(Collection files) {
files.stream().map(file -> unchecked(() -> {
return Files.readString(file.toPath());
})).forEach(System.out::println);
}
```
## Download
You can download the binary from [Maven Central](https://search.maven.org/search?q=g:io.johnsonlee.lambda).