* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.serialization.tinkerpop;
+import java.util.Iterator;
+
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
-import java.util.Iterator;
-
-
/**
- * Represents a {@link Edge} that is disconnected from a {@link Graph} however,
+ * Represents a {@link Edge} that is disconnected from a {@link Graph} however,
* traversals are supported as they are backed by a Tree with saturated {@link Vertex} and {@link Edge} objects.
* These objects are not mutable and can only be used to read information out.
*
*/
public class TreeBackedEdge extends DetachedEdge implements Edge {
- private static final long serialVersionUID = 5419650145562077538L;
- private TreeBackedVertex inVertex;
- private TreeBackedVertex outVertex;
- public TreeBackedEdge(Edge edge, TreeBackedVertex inVertex, TreeBackedVertex outVertex) {
- super(edge, true);
- this.inVertex = inVertex;
- this.outVertex = outVertex;
- }
-
- @Override
- public Vertex inVertex() {
- return this.inVertex;
- }
-
- @Override
- public Vertex outVertex() {
- return this.outVertex;
- }
-
- @Override
- public Iterator<Vertex> bothVertices() {
- return this.vertices(Direction.BOTH);
- }
-
- @Override
- public Iterator<Vertex> vertices(Direction direction) {
- switch (direction) {
- case OUT:
- return IteratorUtils.of(this.outVertex);
- case IN:
- return IteratorUtils.of(this.inVertex);
- default:
- return IteratorUtils.of(this.outVertex, this.inVertex);
- }
- }
+ private static final long serialVersionUID = 5419650145562077538L;
+ private TreeBackedVertex inVertex;
+ private TreeBackedVertex outVertex;
+
+ public TreeBackedEdge(Edge edge, TreeBackedVertex inVertex, TreeBackedVertex outVertex) {
+ super(edge, true);
+ this.inVertex = inVertex;
+ this.outVertex = outVertex;
+ }
+
+ @Override
+ public Vertex inVertex() {
+ return this.inVertex;
+ }
+
+ @Override
+ public Vertex outVertex() {
+ return this.outVertex;
+ }
+ @Override
+ public Iterator<Vertex> bothVertices() {
+ return this.vertices(Direction.BOTH);
+ }
-
+ @Override
+ public Iterator<Vertex> vertices(Direction direction) {
+ switch (direction) {
+ case OUT:
+ return IteratorUtils.of(this.outVertex);
+ case IN:
+ return IteratorUtils.of(this.inVertex);
+ default:
+ return IteratorUtils.of(this.outVertex, this.inVertex);
+ }
+ }
}