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/05/29 20:43:33 UTC
[30/31] incubator-tinkerpop git commit: merged master.
merged master.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/7b528b21
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/7b528b21
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/7b528b21
Branch: refs/heads/master
Commit: 7b528b218b98eefd95f979525850800985bf8e9f
Parents: c19398c a1d26be
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri May 29 12:41:20 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri May 29 12:41:20 2015 -0600
----------------------------------------------------------------------
.../gremlin/structure/util/Comparators.java | 26 ++++-
.../gremlin/structure/util/ElementHelper.java | 53 +++++----
.../gremlin/structure/util/ComparatorsTest.java | 111 +++++++++++++++++++
.../structure/util/ElementHelperTest.java | 79 ++++++++++---
.../ser/JsonMessageSerializerV1d0Test.java | 2 +-
5 files changed, 224 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/7b528b21/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelper.java
----------------------------------------------------------------------
diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelper.java
index b5aa7f3,0245086..9f2a19a
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelper.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelper.java
@@@ -66,35 -65,6 +65,16 @@@ public final class ElementHelper
throw Element.Exceptions.labelCanNotBeAHiddenKey(label);
}
- /*public static void validateLabels(final String... labels) throws IllegalArgumentException {
- for (final String label : labels) {
- validateLabel(label);
- }
- }*/
-
- /**
- * Check if the vertex, by ID, exists. If it does return it, else create it and return it.
- *
- * @param graph the graph to check for the existence of the vertex
- * @param id the id of the vertex to look for
- * @param label the label of the vertex to set if the vertex does not exist
- * @return a pre-existing vertex or a newly created vertex
- */
- public static Vertex getOrAddVertex(final Graph graph, final Object id, final String label) {
- final Iterator<Vertex> iterator = graph.vertices(id);
- return iterator.hasNext() ? iterator.next() : graph.addVertex(T.id, id, T.label, label);
- }
-
+ public static void validateMixedElementIds(final Class<? extends Element> clazz, final Object... ids) {
+ if (ids.length > 1) {
+ final boolean element = clazz.isAssignableFrom(ids[0].getClass());
+ for (int i = 1; i < ids.length; i++) {
+ if (clazz.isAssignableFrom(ids[i].getClass()) != element)
+ throw Graph.Exceptions.idArgsMustBeEitherIdOrElement();
+ }
+ }
+ }
+
/**
* Determines whether the property key/value for the specified thing can be legally set. This is typically used as
* a pre-condition check prior to setting a property.
@@@ -276,27 -265,8 +275,28 @@@
}
/**
- * Assign key/value pairs as properties to a {@link Vertex}. If the value of {@link T#id} or
+ * Assign key/value pairs as properties to an {@link org.apache.tinkerpop.gremlin.structure.Vertex}. If the value of {@link T#id} or
- * {@link T#label} is in the set of pairs, then they are ignored. The {@link org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality} of the key is determined from the {@link org.apache.tinkerpop.gremlin.structure.Graph.Features.VertexFeatures}.
+ * {@link T#label} is in the set of pairs, then they are ignored.
++ * The {@link org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality} of the key is determined from the {@link org.apache.tinkerpop.gremlin.structure.Graph.Features.VertexFeatures}.
+ *
+ * @param vertex the graph vertex to assign the {@code propertyKeyValues}
+ * @param propertyKeyValues the key/value pairs to assign to the {@code element}
+ * @throws ClassCastException if the value of the key is not a {@link String}
+ * @throws IllegalArgumentException if the value of {@code element} is null
+ */
+ public static void attachProperties(final Vertex vertex, final Object... propertyKeyValues) {
+ if (null == vertex)
+ throw Graph.Exceptions.argumentCanNotBeNull("vertex");
+
+ for (int i = 0; i < propertyKeyValues.length; i = i + 2) {
+ if (!propertyKeyValues[i].equals(T.id) && !propertyKeyValues[i].equals(T.label))
+ vertex.property(vertex.graph().features().vertex().getCardinality((String) propertyKeyValues[i]), (String) propertyKeyValues[i], propertyKeyValues[i + 1]);
+ }
+ }
+
+ /**
- * Assign key/value pairs as properties to a {@link org.apache.tinkerpop.gremlin.structure.Vertex}. If the value of {@link T#id} or
- * {@link T#label} is in the set of pairs, then they are ignored.
++ * Assign key/value pairs as properties to a {@link org.apache.tinkerpop.gremlin.structure.Vertex}.
++ * If the value of {@link T#id} or {@link T#label} is in the set of pairs, then they are ignored.
*
* @param vertex the vertex to attach the properties to
* @param cardinality the cardinality of the key value pair settings
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/7b528b21/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelperTest.java
----------------------------------------------------------------------
diff --cc gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelperTest.java
index 0ca3814,0c8dd4a..e8ec27c
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelperTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelperTest.java
@@@ -18,12 -18,14 +18,14 @@@
*/
package org.apache.tinkerpop.gremlin.structure.util;
+ import org.apache.tinkerpop.gremlin.TestHelper;
-import org.apache.tinkerpop.gremlin.structure.T;
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.Property;
+import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
+ import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.javatuples.Pair;
import org.junit.Test;