I am trying to check first that whether a particular Vertex Exists in a graph or not if, it doesn't exists then i am creating a new vertex, the checker is based on properties , Here is the following code :
public Vertex addVertex(Enum label, Map properties){
Vertex x = null;int fl=0,f=0;
if(properties.size()==0)
return null;
GraphTraversalSource g = graph.traversal();
Set<Enum> keys = properties.keySet();
for(Enum key: keys){
f++;
properties.get(key);
System.out.println("enter");
if(g.V().hasLabel(label.toString()).has(key.toString(),properties.get(key)).next()!=null ){
fl++;
System.out.println("exit");
x= g.V().hasLabel(label.toString()).has(key.toString(),properties.get(key)).next();
System.out.println("exit2");
}
}
if(fl==f){
return x;
}
x=graph.addVertex(T.label,label.toString(),properties);
return x;
}
But i am getting the following error .
Exception in thread "main" org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException
How can this be solved, any leads will be really appreciated