Skip to content

Commit 65338ff

Browse files
committed
updated README and CHANGELOG
1 parent 003438a commit 65338ff

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## 3.1 (released 21.01.2025)
4+
5+
- changed lazy methods access modifier to public
6+
- removed unnecessary JKScope.main method
7+
- added lazyOf methods test
8+
- added new recur methods tests
9+
- added null checks for lazy methods args
10+
11+
## 3.0 (released 20.01.2025)
12+
13+
- big refactoring, no backward compatibility
14+
315
## 2.3 (released 10.03.2024)
416

517
- added `Lazy` object and `JKScope` methods

README.md

+34-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Java scope functions inspired by Kotlin
3232
* [Collection initialization](#collection-initialization)
3333
* [Argument in a method chain](#argument-in-a-method-chain)
3434
* [Nth Fibonacci number](#nth-fibonacci-number)
35+
* [Get all related exceptions via recursion](#get-all-related-exceptions-via-recursion)
36+
* [Get all related exceptions via iteration](#get-all-related-exceptions-via-iteration)
3537

3638
## Motivation
3739

@@ -44,11 +46,10 @@ Java 8+ version required. The library has no dependencies.
4446
Maven:
4547

4648
```xml
47-
4849
<dependency>
4950
<groupId>com.plugatar.jkscope</groupId>
5051
<artifactId>jkscope</artifactId>
51-
<version>3.0</version>
52+
<version>3.1</version>
5253
<scope>compile</scope>
5354
</dependency>
5455
```
@@ -57,7 +58,7 @@ Gradle:
5758

5859
```groovy
5960
dependencies {
60-
implementation 'com.plugatar.jkscope:jkscope:3.0'
61+
implementation 'com.plugatar.jkscope:jkscope:3.1'
6162
}
6263
```
6364

@@ -439,7 +440,7 @@ All presented functions allow you to not catch any checked exceptions.
439440

440441
```
441442
public static void main(String[] args) {
442-
URI uri = let(() -> new URI("abc"));
443+
URI uri = it(() -> new URI("abc"));
443444
}
444445
```
445446

@@ -476,11 +477,39 @@ new MyBuilder()
476477
#### Nth Fibonacci number
477478

478479
```
479-
int value = recur1(10, (n, func) -> {
480+
int result = recur1(10, (n, func) -> {
480481
if (n <= 1) {
481482
return 1;
482483
} else {
483484
return n * func.apply(n - 1);
484485
}
485486
});
486487
```
488+
489+
#### Get all related exceptions via recursion
490+
491+
```
492+
Throwable mainException = ...;
493+
Set<Throwable> allRelated = recur1(mainException, new HashSet<>(), (currentEx, set, self) -> {
494+
if (currentEx != null && set.add(currentEx)) {
495+
self.accept(currentEx.getCause());
496+
for (final Throwable suppressedEx : currentEx.getSuppressed()) {
497+
self.accept(suppressedEx);
498+
}
499+
}
500+
});
501+
```
502+
503+
#### Get all related exceptions via iteration
504+
505+
```
506+
Throwable mainException = ...;
507+
Set<Throwable> allRelated = iterate1(mainException, new HashSet<>(), (currentEx, set, nextValues) -> {
508+
if (currentEx != null && set.add(currentEx)) {
509+
nextValues.push(currentEx.getCause());
510+
for (final Throwable suppressedEx : currentEx.getSuppressed()) {
511+
nextValues.push(suppressedEx);
512+
}
513+
}
514+
});
515+
```

0 commit comments

Comments
 (0)