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 2017/09/28 20:06:09 UTC
[2/9] tinkerpop git commit: In GraphComputer,
labels of adjacent vertices can not be accessed. Thus,
ReferenceElement needs to ensure that label() doesn't throw an
UnsupportedOperationException. I borrowed the same technique used in
DeatchedElement.
In GraphComputer, labels of adjacent vertices can not be accessed. Thus, ReferenceElement needs to ensure that label() doesn't throw an UnsupportedOperationException. I borrowed the same technique used in DeatchedElement.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/acbc18dd
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/acbc18dd
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/acbc18dd
Branch: refs/heads/tp32
Commit: acbc18ddc37a6a9453d672a0b4f64bcace9cf6cf
Parents: d6cb13e
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu Sep 21 13:31:18 2017 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu Sep 21 13:31:18 2017 -0600
----------------------------------------------------------------------
.../util/reference/ReferenceElement.java | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/acbc18dd/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
index 14e5ab3..1603cfb 100644
--- 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
@@ -18,10 +18,13 @@
*/
package org.apache.tinkerpop.gremlin.structure.util.reference;
+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.util.ElementHelper;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
+import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
import java.io.Serializable;
@@ -31,6 +34,8 @@ import java.io.Serializable;
*/
public abstract class ReferenceElement<E extends Element> implements Element, Serializable, Attachable<E> {
+ private final static String EMPTY_STRING = "";
+
protected Object id;
protected String label;
@@ -40,7 +45,16 @@ public abstract class ReferenceElement<E extends Element> implements Element, Se
public ReferenceElement(final Element element) {
this.id = element.id();
- this.label = element.label();
+ try {
+ this.label = element.label();
+ } catch (final UnsupportedOperationException e) {
+ if (element instanceof Vertex)
+ this.label = Vertex.DEFAULT_LABEL;
+ else if (element instanceof Edge)
+ this.label = Edge.DEFAULT_LABEL;
+ else
+ this.label = VertexProperty.DEFAULT_LABEL;
+ }
}
@Override