Created
January 15, 2014 15:28
-
-
Save jbrisbin/8438264 to your computer and use it in GitHub Desktop.
Proposed Graph API psuedo-code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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