I am using Tinkerpop3 Gremlin against the reference TinkerGraph implementation.
I am attempting to .next()
a Vertex
out this Traversal:
graph.V().has(T.label, "link").has("url", url).next();
Unfortunately, I am only able to get an Element
from next()
. When I assign the output of next()
into a Vertex
, I get:
error: incompatible types: Element cannot be converted to Vertex
How can I get a Vertex
?
I've looked at the docs and see that V()
returns GraphTraversal<Vertex,Vertex>
. The has()
steps are signed default <E2 extends Element> GraphTraversal<S,E2>
, which I thought would preserve the GraphTraveral<Vertex, Vertex>
but next()
yields only Element
. Not sure what to do next.
Thank you.
Well - you could always do this:
Vertex v = g.V().has(T.label, "link").<Vertex>has("name", url).next();
and simply explicitly type the last step.