Skip to content

Commit 3f92e4c

Browse files
committed
refactor: make TryConsumer public
1 parent bc7cfaf commit 3f92e4c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.bsc.langgraph4j.utils;
2+
3+
import java.util.function.Consumer;
4+
5+
@FunctionalInterface
6+
public interface TryConsumer<T, Ex extends Throwable> extends Consumer<T> {
7+
8+
void tryAccept( T t ) throws Ex;
9+
10+
default void accept( T t ) {
11+
try {
12+
tryAccept(t);
13+
} catch (Throwable ex) {
14+
throw new RuntimeException(ex);
15+
}
16+
}
17+
18+
static <T,Ex extends Throwable> Consumer<T> Try( TryConsumer<T, Ex> consumer ) {
19+
return consumer;
20+
}
21+
}

0 commit comments

Comments
 (0)