You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/04/09 00:55:02 UTC

incubator-tinkerpop git commit: ReferenceXXX implemented.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/reference_elements [created] 48580718a


ReferenceXXX implemented.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/48580718
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/48580718
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/48580718

Branch: refs/heads/reference_elements
Commit: 48580718a5e34d5a917e90c007b3bbb308e058ac
Parents: c26342a
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Apr 8 16:54:52 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Apr 8 16:54:52 2015 -0600

----------------------------------------------------------------------
 .../util/detached/DetachedFactory.java          |  4 +
 .../structure/util/reference/ReferenceEdge.java | 75 ++++++++++++++++
 .../util/reference/ReferenceElement.java        | 64 ++++++++++++++
 .../util/reference/ReferenceFactory.java        | 81 ++++++++++++++++++
 .../structure/util/reference/ReferencePath.java | 79 +++++++++++++++++
 .../util/reference/ReferenceProperty.java       | 80 +++++++++++++++++
 .../util/reference/ReferenceVertex.java         | 90 ++++++++++++++++++++
 .../util/reference/ReferenceVertexProperty.java | 88 +++++++++++++++++++
 8 files changed, 561 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/48580718/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedFactory.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedFactory.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedFactory.java
index 31e7905..10265f8 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedFactory.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedFactory.java
@@ -29,6 +29,10 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty;
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
 public class DetachedFactory {
+
+    private DetachedFactory() {
+    }
+
     public static DetachedVertex detach(final Vertex vertex, final boolean withProperties) {
         return vertex instanceof DetachedVertex ? (DetachedVertex) vertex : new DetachedVertex(vertex, withProperties);
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/48580718/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdge.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdge.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdge.java
new file mode 100644
index 0000000..842039d
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdge.java
@@ -0,0 +1,75 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one
+ *  * or more contributor license agreements.  See the NOTICE file
+ *  * distributed with this work for additional information
+ *  * regarding copyright ownership.  The ASF licenses this file
+ *  * to you under the Apache License, Version 2.0 (the
+ *  * "License"); you may not use this file except in compliance
+ *  * with the License.  You may obtain a copy of the License at
+ *  *
+ *  * http://www.apache.org/licenses/LICENSE-2.0
+ *  *
+ *  * Unless required by applicable law or agreed to in writing,
+ *  * software distributed under the License is distributed on an
+ *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  * KIND, either express or implied.  See the License for the
+ *  * specific language governing permissions and limitations
+ *  * under the License.
+ *
+ */
+
+package org.apache.tinkerpop.gremlin.structure.util.reference;
+
+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.Property;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+
+import java.util.Collections;
+import java.util.Iterator;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class ReferenceEdge extends ReferenceElement<Edge> implements Edge {
+
+    public ReferenceEdge(final Edge edge) {
+        super(edge);
+    }
+
+    @Override
+    public Iterator<Vertex> vertices(Direction direction) {
+        return Collections.emptyIterator();
+    }
+
+    @Override
+    public void remove() {
+        throw Edge.Exceptions.edgeRemovalNotSupported();
+    }
+
+    @Override
+    public <V> Iterator<Property<V>> properties(final String... propertyKeys) {
+        return Collections.emptyIterator();
+    }
+
+    @Override
+    public Edge attach(final Vertex hostVertex) {
+        final Iterator<Edge> edges = IteratorUtils.filter(hostVertex.edges(Direction.OUT), edge -> edge.equals(this));
+        if (!edges.hasNext())
+            throw new IllegalStateException("The reference edge could not be found incident to the provided vertex: " + this);
+        return edges.next();
+    }
+
+    @Override
+    public Edge attach(final Graph hostGraph) {
+        final Iterator<Edge> edges = hostGraph.edges(this.id);
+        if (!edges.hasNext())
+            throw new IllegalStateException("The reference edge could not be found in the provided graph: " + this);
+        return edges.next();
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/48580718/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
new file mode 100644
index 0000000..2fce123
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
@@ -0,0 +1,64 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one
+ *  * or more contributor license agreements.  See the NOTICE file
+ *  * distributed with this work for additional information
+ *  * regarding copyright ownership.  The ASF licenses this file
+ *  * to you under the Apache License, Version 2.0 (the
+ *  * "License"); you may not use this file except in compliance
+ *  * with the License.  You may obtain a copy of the License at
+ *  *
+ *  * http://www.apache.org/licenses/LICENSE-2.0
+ *  *
+ *  * Unless required by applicable law or agreed to in writing,
+ *  * software distributed under the License is distributed on an
+ *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  * KIND, either express or implied.  See the License for the
+ *  * specific language governing permissions and limitations
+ *  * under the License.
+ *
+ */
+
+package org.apache.tinkerpop.gremlin.structure.util.reference;
+
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.util.detached.Attachable;
+import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
+
+import java.io.Serializable;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public abstract class ReferenceElement<E extends Element> implements Element, Serializable, Attachable<E> {
+
+    private static final String EMPTY_STRING = "";
+
+    protected final Object id;
+
+    public ReferenceElement(final Element element) {
+        this.id = element.id();
+    }
+
+    @Override
+    public Object id() {
+        return this.id;
+    }
+
+    @Override
+    public String label() {
+        return EMPTY_STRING;
+    }
+
+    @Override
+    public Graph graph() {
+        return EmptyGraph.instance();
+    }
+
+    @Override
+    public <V> Property<V> property(final String key, final V value) {
+        throw Element.Exceptions.propertyAdditionNotSupported();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/48580718/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceFactory.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceFactory.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceFactory.java
new file mode 100644
index 0000000..5a8d1b1
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceFactory.java
@@ -0,0 +1,81 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one
+ *  * or more contributor license agreements.  See the NOTICE file
+ *  * distributed with this work for additional information
+ *  * regarding copyright ownership.  The ASF licenses this file
+ *  * to you under the Apache License, Version 2.0 (the
+ *  * "License"); you may not use this file except in compliance
+ *  * with the License.  You may obtain a copy of the License at
+ *  *
+ *  * http://www.apache.org/licenses/LICENSE-2.0
+ *  *
+ *  * Unless required by applicable law or agreed to in writing,
+ *  * software distributed under the License is distributed on an
+ *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  * KIND, either express or implied.  See the License for the
+ *  * specific language governing permissions and limitations
+ *  * under the License.
+ *
+ */
+
+package org.apache.tinkerpop.gremlin.structure.util.reference;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Path;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class ReferenceFactory {
+
+    private ReferenceFactory() {
+    }
+
+    public static ReferenceVertex detach(final Vertex vertex) {
+        return vertex instanceof ReferenceVertex ? (ReferenceVertex) vertex : new ReferenceVertex(vertex);
+    }
+
+    public static ReferenceEdge detach(final Edge edge) {
+        return edge instanceof ReferenceEdge ? (ReferenceEdge) edge : new ReferenceEdge(edge);
+    }
+
+    public static <V> ReferenceVertexProperty detach(final VertexProperty<V> vertexProperty) {
+        return vertexProperty instanceof ReferenceVertexProperty ? (ReferenceVertexProperty) vertexProperty : new ReferenceVertexProperty<>(vertexProperty);
+    }
+
+    public static <V> ReferenceProperty<V> detach(final Property<V> property) {
+        return property instanceof ReferenceProperty ? (ReferenceProperty<V>) property : new ReferenceProperty<>(property.key(), ReferenceFactory.detach(property.element()));
+    }
+
+    public static ReferencePath detach(final Path path) {
+        return path instanceof ReferencePath ? (ReferencePath) path : new ReferencePath(path);
+    }
+
+    public static ReferenceElement detach(final Element element) {
+        if (element instanceof Vertex)
+            return detach((Vertex) element);
+        else if (element instanceof Edge)
+            return detach((Edge) element);
+        else if (element instanceof VertexProperty)
+            return detach((VertexProperty) element);
+        else
+            throw new IllegalArgumentException("The provided argument is an unknown element: " + element + ':' + element.getClass());
+    }
+
+    public static <D> D detach(final Object object) {
+        if (object instanceof Element) {
+            return (D) ReferenceFactory.detach((Element) object);
+        } else if (object instanceof Property) {
+            return (D) ReferenceFactory.detach((Property) object);
+        } else if (object instanceof Path) {
+            return (D) ReferenceFactory.detach((Path) object);
+        } else {
+            return (D) object;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/48580718/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
new file mode 100644
index 0000000..696bc44
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
@@ -0,0 +1,79 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one
+ *  * or more contributor license agreements.  See the NOTICE file
+ *  * distributed with this work for additional information
+ *  * regarding copyright ownership.  The ASF licenses this file
+ *  * to you under the Apache License, Version 2.0 (the
+ *  * "License"); you may not use this file except in compliance
+ *  * with the License.  You may obtain a copy of the License at
+ *  *
+ *  * http://www.apache.org/licenses/LICENSE-2.0
+ *  *
+ *  * Unless required by applicable law or agreed to in writing,
+ *  * software distributed under the License is distributed on an
+ *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  * KIND, either express or implied.  See the License for the
+ *  * specific language governing permissions and limitations
+ *  * under the License.
+ *
+ */
+
+package org.apache.tinkerpop.gremlin.structure.util.reference;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Path;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.MutablePath;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.util.detached.Attachable;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class ReferencePath extends MutablePath implements Attachable<Path> {
+
+    private ReferencePath() {
+
+    }
+
+    protected ReferencePath(final Path path) {
+        path.forEach((object, labels) -> {
+            if (object instanceof ReferenceElement || object instanceof ReferenceProperty || object instanceof ReferencePath) {
+                this.objects.add(object);
+                this.labels.add(labels);
+            } else if (object instanceof Element) {
+                this.objects.add(ReferenceFactory.detach((Element) object));
+                this.labels.add(labels);
+            } else if (object instanceof Property) {
+                this.objects.add(ReferenceFactory.detach((Property) object));
+                this.labels.add(labels);
+            } else if (object instanceof Path) {
+                this.objects.add(ReferenceFactory.detach((Path) object));
+                this.labels.add(labels);
+            } else {
+                this.objects.add(object);
+                this.labels.add(labels);
+            }
+        });
+    }
+
+    @Override
+    public Path attach(final Graph hostGraph) {
+        final Path path = MutablePath.make();  // TODO: Use ImmutablePath?
+        this.forEach((object, labels) -> path.extend(object instanceof Attachable ? ((Attachable) object).attach(hostGraph) : object, labels.toArray(new String[labels.size()])));
+        return path;
+    }
+
+    @Override
+    public Path attach(final Vertex hostVertex) {
+        final Path path = MutablePath.make();  // TODO: Use ImmutablePath?
+        this.forEach((object, labels) -> path.extend(object instanceof Attachable ? ((Attachable) object).attach(hostVertex) : object, labels.toArray(new String[labels.size()])));
+        return path;
+    }
+
+    public String toString() {
+        return this.objects.toString();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/48580718/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
new file mode 100644
index 0000000..fdac259
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
@@ -0,0 +1,80 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one
+ *  * or more contributor license agreements.  See the NOTICE file
+ *  * distributed with this work for additional information
+ *  * regarding copyright ownership.  The ASF licenses this file
+ *  * to you under the Apache License, Version 2.0 (the
+ *  * "License"); you may not use this file except in compliance
+ *  * with the License.  You may obtain a copy of the License at
+ *  *
+ *  * http://www.apache.org/licenses/LICENSE-2.0
+ *  *
+ *  * Unless required by applicable law or agreed to in writing,
+ *  * software distributed under the License is distributed on an
+ *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  * KIND, either express or implied.  See the License for the
+ *  * specific language governing permissions and limitations
+ *  * under the License.
+ *
+ */
+
+package org.apache.tinkerpop.gremlin.structure.util.reference;
+
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.util.detached.Attachable;
+
+import java.io.Serializable;
+import java.util.NoSuchElementException;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class ReferenceProperty<V> implements Property, Attachable<Property<V>>, Serializable {
+
+    private ReferenceElement<?> element;
+    private String key;
+
+    public ReferenceProperty(final String key,final ReferenceElement<?> element) {
+        this.element = element;
+        this.key = key;
+    }
+
+    @Override
+    public Property<V> attach(final Vertex hostVertex) throws IllegalStateException {
+        return this.element.attach(hostVertex).property(this.key);
+    }
+
+    @Override
+    public Property<V> attach(final Graph hostGraph) throws IllegalStateException {
+        return this.element.attach(hostGraph).property(this.key);
+    }
+
+    @Override
+    public String key() {
+        return this.key;
+    }
+
+    @Override
+    public Object value() throws NoSuchElementException {
+        return null;
+    }
+
+    @Override
+    public boolean isPresent() {
+        return false;
+    }
+
+    @Override
+    public Element element() {
+        return this.element;
+    }
+
+    @Override
+    public void remove() {
+        throw Element.Exceptions.propertyRemovalNotSupported();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/48580718/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertex.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertex.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertex.java
new file mode 100644
index 0000000..b2293ce
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertex.java
@@ -0,0 +1,90 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one
+ *  * or more contributor license agreements.  See the NOTICE file
+ *  * distributed with this work for additional information
+ *  * regarding copyright ownership.  The ASF licenses this file
+ *  * to you under the Apache License, Version 2.0 (the
+ *  * "License"); you may not use this file except in compliance
+ *  * with the License.  You may obtain a copy of the License at
+ *  *
+ *  * http://www.apache.org/licenses/LICENSE-2.0
+ *  *
+ *  * Unless required by applicable law or agreed to in writing,
+ *  * software distributed under the License is distributed on an
+ *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  * KIND, either express or implied.  See the License for the
+ *  * specific language governing permissions and limitations
+ *  * under the License.
+ *
+ */
+
+package org.apache.tinkerpop.gremlin.structure.util.reference;
+
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+
+import java.util.Collections;
+import java.util.Iterator;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class ReferenceVertex extends ReferenceElement<Vertex> implements Vertex {
+
+    public ReferenceVertex(final Vertex vertex) {
+        super(vertex);
+    }
+
+    @Override
+    public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
+        throw Vertex.Exceptions.edgeAdditionsNotSupported();
+    }
+
+    @Override
+    public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) {
+        throw Element.Exceptions.propertyAdditionNotSupported();
+    }
+
+    @Override
+    public Iterator<Edge> edges(final Direction direction, final String... edgeLabels) {
+        return Collections.emptyIterator();
+    }
+
+    @Override
+    public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) {
+        return Collections.emptyIterator();
+    }
+
+    @Override
+    public void remove() {
+        throw Vertex.Exceptions.vertexRemovalNotSupported();
+    }
+
+    @Override
+    public <V> Iterator<VertexProperty<V>> properties(final String... propertyKeys) {
+        return Collections.emptyIterator();
+    }
+
+    @Override
+    public <V> VertexProperty<V> property(final String key, final V value) {
+        throw Element.Exceptions.propertyAdditionNotSupported();
+    }
+
+    @Override
+    public Vertex attach(final Vertex hostVertex) {
+        if (hostVertex.equals(this))
+            return hostVertex;
+        else
+            throw new IllegalStateException("The host vertex must be the reference vertex to attach: " + this + "!=" + hostVertex);
+    }
+
+    @Override
+    public Vertex attach(final Graph hostGraph) {
+        return hostGraph.vertices(this.id).next();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/48580718/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexProperty.java
new file mode 100644
index 0000000..01e25ff
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexProperty.java
@@ -0,0 +1,88 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one
+ *  * or more contributor license agreements.  See the NOTICE file
+ *  * distributed with this work for additional information
+ *  * regarding copyright ownership.  The ASF licenses this file
+ *  * to you under the Apache License, Version 2.0 (the
+ *  * "License"); you may not use this file except in compliance
+ *  * with the License.  You may obtain a copy of the License at
+ *  *
+ *  * http://www.apache.org/licenses/LICENSE-2.0
+ *  *
+ *  * Unless required by applicable law or agreed to in writing,
+ *  * software distributed under the License is distributed on an
+ *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  * KIND, either express or implied.  See the License for the
+ *  * specific language governing permissions and limitations
+ *  * under the License.
+ *
+ */
+
+package org.apache.tinkerpop.gremlin.structure.util.reference;
+
+import org.apache.tinkerpop.gremlin.process.traversal.FastNoSuchElementException;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class ReferenceVertexProperty<V> extends ReferenceElement<VertexProperty> implements VertexProperty<V> {
+
+    public ReferenceVertexProperty(final VertexProperty vertexProperty) {
+        super(vertexProperty);
+    }
+
+    @Override
+    public String key() {
+        return null;
+    }
+
+    @Override
+    public V value() throws NoSuchElementException {
+        throw FastNoSuchElementException.instance();
+    }
+
+    @Override
+    public boolean isPresent() {
+        return false;
+    }
+
+    @Override
+    public Vertex element() {
+        return null;
+    }
+
+    @Override
+    public void remove() {
+        throw Element.Exceptions.propertyRemovalNotSupported();
+    }
+
+    @Override
+    public <U> Iterator<Property<U>> properties(String... propertyKeys) {
+        return Collections.emptyIterator();
+    }
+
+    @Override
+    public VertexProperty<V> attach(final Vertex hostVertex) {
+        final Iterator<VertexProperty<V>> vertexPropertyIterator = IteratorUtils.filter(hostVertex.<V>properties(), vp -> ElementHelper.areEqual(this, vp));
+        if (!vertexPropertyIterator.hasNext())
+            throw new IllegalStateException("The reference vertex property could not be be found at the provided vertex: " + this);
+        return vertexPropertyIterator.next();
+    }
+
+    @Override
+    public VertexProperty<V> attach(final Graph hostGraph) {
+        throw new UnsupportedOperationException();
+    }
+}