[[https://raw.github.com/tinkerpop/frames/master/doc/images/gremlin-in-frames.png|align=left]]

"Gremlin":http://gremlin.tinkerpop.com is the graph traversal language of the TinkerPop stack and provides a concise syntax for traversing a "Blueprints":http://blueprints.tinkerpop.com graph data structure. Frames leverages Gremlin via annotations in order to allow methods to do more complex computations/traversals than direct incidences and adjacencies as seen with the core Frames annotations.

h2. Frame Adjacencies

It is possible to make use of a Gremlin path expression as a means of determining vertex adjacency via the @GremlinGroovyModule@.

|_. annotation |_. method prefix |_. arguments |_. description |_. example |
| @@GremlinGroovy@ | @get@ | @value@ | get and frame the vertices at then end of the expression | @@GremlinGroovy("it.out('knows')")@ |
| @@GremlinGroovy@ | @get@, @can@, @is@ | @value@, @frame=false@ | return the objects at then end of the expression | @@GremlinGroovy(value="it.out('knows').name", frame=false)@ |

```java
public interface Person {
    @GremlinGroovy("it.as('x').out('created').in('created').except('x')")
    public Iterable<Person> getCoCreators();
}
```

In the example above, the vertices at the end of the path expression are framed as @Person@ classes.

```java
FramedGraphFactory factory = new FramedGraphFactory(new GremlinGroovyModule()); //Use the gremlin groovy module
FramedGraph framedGraph = factory.create(graph);

Person marko = framedGraph.frame(graph.getVertex(1), Person.class);
for (Person coCreator : marko.getCoCreators()) {
  System.out.println(coCreator.getName());
}
// josh
// peter
```

When constructing your @FramedGraphFactory@ ensure you include the @GremlinGroovyModule@.

You can also pass parameters to the gremlin expression by using @@GremlinParam@ to specify the name of the parameter.

```java
public interface Person {
    @GremlinGroovy("it.as('x').out('created').in('created').except('x').has('age',age)")
    public Iterable<Person> getCoCreatorsOfAge(@GremlinParam("age") int age);
}
```

In this example the paramater named 'age' is passed to the script.

```java
Person josh = marko.getCoCreatorsOfAge(32).iterator().next();
```

h2. Arbitrary Java objects

If the resultant object return type is not a Frame, then @frame=false@ should be used in the @@GremlinGroovy@ annotation.

```java
@GremlinGroovy(value="'1+2'", frame=false)
public Integer getASumOfTwoNumbers();
```