Skip to content

Instantly share code, notes, and snippets.

@jbrisbin
Created January 15, 2014 15:28
Show Gist options
  • Save jbrisbin/8438264 to your computer and use it in GitHub Desktop.
Save jbrisbin/8438264 to your computer and use it in GitHub Desktop.
Proposed Graph API psuedo-code
class GraphSpec<T> {}
class NodeSpec<T> {}
class State<T> {}
GraphSpec<T> graph = Graphs.compose()
.env(env)
.dispatcher(dispatcher)
.create("bad arg handler", new Consumer<State<Throwable>>(){})
.create("global err handler", new Consumer<State<Throwable>>(){});
NodeSpec<T> n1 = graph.when("condition name", new Predicate<State<T>>(){})
.swap(new Function<State<T>, State<V>>(){})
.then().end(new Consumer<State<V>>(){})
.otherwise()
.end(new Function<State<T>, State<V>>(){});
NodeSpec<T> n2 = graph.when(IllegalArgumentException.class)
.then(new Consumer<State<IllegalArgumentException>>(){}, dispatcher)
.otherwise()
.end("global err handler");
graph.get().accept(value);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment