Created
February 5, 2014 17:03
-
-
Save okram/8828362 to your computer and use it in GitHub Desktop.
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
////////////////////////////////// | |
///////// BLUEPRINTS //////////// | |
///////////////////////////////// | |
public interface Graph { | |
public <S, A extends Flow<A, S, Vertex>> A V(); | |
... | |
} | |
public interface Flow<A extends Flow, S, E> { | |
public A has(String key, Object value); | |
public A out(); | |
public A value(String key); | |
} | |
public class GremlinFlow<S, E> implements Flow<GremlinFlow, S, E> { | |
public GremlinFlow has(String key, Object value) { | |
return this; | |
} | |
public GremlinFlow out() { | |
return this; | |
} | |
public GremlinFlow value(String key) { | |
return this; | |
} | |
} | |
////////////////////////////////// | |
///////// TINKERGRAPH //////////// | |
////////////////////////////////// | |
public class TinkerGraph { | |
public <S, A extends Flow<A, S, Vertex>> A V() { | |
return (A) new GremlinFlow<S, Vertex>(); | |
} | |
... | |
} | |
/// EXAMPLE TEST -- RETURNS NOTHING, BUT DEMONSTRATES THE FUNCTION CHAINING OFF g.V() | |
@Test | |
public void shouldFlow() { | |
Graph g = TinkerFactory.createClassic(); | |
g.V().has("name","marko").out(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment