graphVariables.entrySet().forEach(entry -> graphToWriteTo.variables().set(entry.getKey(), entry.getValue()));
} else if (fieldName.equals(GraphSONTokens.VERTICES)) {
while (parser.nextToken() != JsonToken.END_ARRAY) {
final Map<String, Object> vertexData = parser.readValueAs(mapTypeReference);
readVertexData(vertexData, detachedVertex -> {
final Vertex v = Optional.ofNullable(graph.v(detachedVertex.id())).orElse(
graph.addVertex(T.label, detachedVertex.label(), T.id, detachedVertex.id()));
detachedVertex.iterators().propertyIterator().forEachRemaining(p -> createVertexProperty(graphToWriteTo, v, p, false));
detachedVertex.iterators().hiddenPropertyIterator().forEachRemaining(p -> createVertexProperty(graphToWriteTo, v, p, true));
return v;
});
}
} else if (fieldName.equals(GraphSONTokens.EDGES)) {
while (parser.nextToken() != JsonToken.END_ARRAY) {
final Map<String, Object> edgeData = parser.readValueAs(mapTypeReference);
readEdgeData(edgeData, detachedEdge -> {
final Vertex vOut = graph.v(detachedEdge.iterators().vertexIterator(Direction.OUT).next().id());
final Vertex vIn = graph.v(detachedEdge.iterators().vertexIterator(Direction.IN).next().id());
// batchgraph checks for edge id support and uses it if possible.
final Edge e = vOut.addEdge(edgeData.get(GraphSONTokens.LABEL).toString(), vIn, T.id, detachedEdge.id());
detachedEdge.iterators().propertyIterator().forEachRemaining(p -> e.<Object>property(p.key(), p.value()));
detachedEdge.iterators().hiddenPropertyIterator().forEachRemaining(p -> e.<Object>property(Graph.Key.hide(p.key()), p.value()));
return e;