// Path: driver/src/main/java/org/apache/tinkerpop/gremlin/orientdb/StreamUtils.java
// public static <T> Stream<T> asStream(Iterator<T> sourceIterator) {
//   return asStream(sourceIterator, false);
// }


import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.apache.tinkerpop.gremlin.orientdb.StreamUtils.asStream;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.record.OEdge;
import com.orientechnologies.orient.core.record.OVertex;
import com.orientechnologies.orient.core.record.impl.ODocument;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.tinkerpop.gremlin.structure.*;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
  }

  @Override
  public Edge addEdge(String label, Vertex inVertex, Object... keyValues) {
    if (inVertex == null) throw new IllegalArgumentException("destination vertex is null");
    checkArgument(!isNullOrEmpty(label), "label is invalid");

    ElementHelper.legalPropertyKeyValueArray(keyValues);
    if (ElementHelper.getIdValue(keyValues).isPresent())
      throw Vertex.Exceptions.userSuppliedIdsNotSupported();
    if (Graph.Hidden.isHidden(label)) throw Element.Exceptions.labelCanNotBeAHiddenKey(label);

    graph.createEdgeClass(label);

    this.graph.tx().readWrite();

    OEdge oEdge = getRawElement().addEdge(((OrientVertex) inVertex).getRawElement(), label);
    final OrientEdge edge = graph.elementFactory().wrapEdge(oEdge);
    edge.property(keyValues);

    edge.save();
    return edge;
  }

  public Iterator<Edge> edges(final Direction direction, String... edgeLabels) {
    this.graph.tx().readWrite();
    // It should not collect but instead iterating through the relations.
    // But necessary in order to avoid loop in
    // EdgeTest#shouldNotHaveAConcurrentModificationExceptionWhenIteratingAndRemovingAddingEdges
    Stream<Edge> edgeStream =
// Path: driver/src/main/java/org/apache/tinkerpop/gremlin/orientdb/StreamUtils.java
// public static <T> Stream<T> asStream(Iterator<T> sourceIterator) {
//   return asStream(sourceIterator, false);
// }


// Path: driver/src/main/java/org/apache/tinkerpop/gremlin/orientdb/OrientVertex.java
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.apache.tinkerpop.gremlin.orientdb.StreamUtils.asStream;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.record.OEdge;
import com.orientechnologies.orient.core.record.OVertex;
import com.orientechnologies.orient.core.record.impl.ODocument;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.tinkerpop.gremlin.structure.*;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;

  }

  @Override
  public Edge addEdge(String label, Vertex inVertex, Object... keyValues) {
    if (inVertex == null) throw new IllegalArgumentException("destination vertex is null");
    checkArgument(!isNullOrEmpty(label), "label is invalid");

    ElementHelper.legalPropertyKeyValueArray(keyValues);
    if (ElementHelper.getIdValue(keyValues).isPresent())
      throw Vertex.Exceptions.userSuppliedIdsNotSupported();
    if (Graph.Hidden.isHidden(label)) throw Element.Exceptions.labelCanNotBeAHiddenKey(label);

    graph.createEdgeClass(label);

    this.graph.tx().readWrite();

    OEdge oEdge = getRawElement().addEdge(((OrientVertex) inVertex).getRawElement(), label);
    final OrientEdge edge = graph.elementFactory().wrapEdge(oEdge);
    edge.property(keyValues);

    edge.save();
    return edge;
  }

  public Iterator<Edge> edges(final Direction direction, String... edgeLabels) {
    this.graph.tx().readWrite();
    // It should not collect but instead iterating through the relations.
    // But necessary in order to avoid loop in
    // EdgeTest#shouldNotHaveAConcurrentModificationExceptionWhenIteratingAndRemovingAddingEdges
    Stream<Edge> edgeStream =
        asStream(