Skip to content

Commit

Permalink
refactor: make TryConsumer public
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Aug 28, 2024
1 parent 3f92e4c commit 2447a23
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions core-jdk8/src/main/java/org/bsc/langgraph4j/CompiledGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.bsc.langgraph4j.serializer.MapSerializer;
import org.bsc.langgraph4j.state.AgentState;
import org.bsc.langgraph4j.state.StateSnapshot;
import org.bsc.langgraph4j.utils.TryConsumer;

import java.io.IOException;
import java.util.*;
Expand All @@ -24,26 +25,6 @@
import static org.bsc.langgraph4j.StateGraph.END;
import static org.bsc.langgraph4j.StateGraph.START;


@FunctionalInterface
interface TryConsumer<T, Ex extends Throwable> extends Consumer<T> {

void tryAccept( T t ) throws Ex;

default void accept( T t ) {
try {
tryAccept(t);
} catch (Throwable ex) {
throw new RuntimeException(ex);
}
}

static <T,Ex extends Throwable> Consumer<T> Try( TryConsumer<T, Ex> consumer ) {
return consumer;
}
}


/**
* Represents a compiled graph of nodes and edges.
* This class manage the StateGraph execution
Expand Down

0 comments on commit 2447a23

Please sign in to comment.