bechbd commented on a change in pull request #1533:
URL: https://github.com/apache/tinkerpop/pull/1533#discussion_r777765439
##########
File path:
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
##########
@@ -2364,14 +2373,58 @@ else if (value instanceof Traversal)
* @since 3.0.0-incubating
*/
public default GraphTraversal<S, E> property(final Object key, final
Object value, final Object... keyValues) {
- return key instanceof VertexProperty.Cardinality ?
- this.property((VertexProperty.Cardinality) key, value, null ==
keyValues ? null : keyValues[0],
+ if (key instanceof VertexProperty.Cardinality) {
+ if (value instanceof Map) { //Handle the property(Cardinality,
Map) signature
+ final Map<Object, Object> map = (Map)value;
+ for (Map.Entry<Object, Object> entry : map.entrySet()) {
+ property(key, entry.getKey(), entry.getValue());
+ }
+ return this;
+ } else {
+ return this.property((VertexProperty.Cardinality) key, value,
null == keyValues ? null : keyValues[0],
keyValues != null && keyValues.length > 1 ?
Arrays.copyOfRange(keyValues, 1,
keyValues.length) :
- new Object[]{}) :
- this.property(null, key, value, keyValues);
+ new Object[]{});
+ }
+ } else { //handles if cardinality is not the first parameter
+ if (value instanceof Map) { //Handle the property(Cardinality,
Map) signature
+ final Map<Object, Object> map = (Map)value;
+ for (Map.Entry<Object, Object> entry : map.entrySet()) {
+ property(null, entry.getKey(), entry.getValue());
+ }
+ return this;
+ } else {
+ return this.property(null, key, value, keyValues);
+ }
+ }
+ }
+
+ /**
+ * When a {@link Map} is supplied and if supported by the {@link Graph}
then each of the key/value pairs in the map will
+ * be added as property. This method is the long-hand version of looping
through the
+ * {@link #property(Object, Object, Object...)} method for each key/value
pair supplied.
+ * <p/>
+ * If a {@link Map} is not supplied then an exception is thrown.
+ * <p />
+ * This method is effectively calls {@link
#property(VertexProperty.Cardinality, Object, Object, Object...)}
+ * as {@code property(null, key, value, keyValues}.
+ *
+ * @param value the value for the property
+ * @return the traversal with the last step modified to add a property
+ * @see <a
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addproperty-step"
target="_blank">AddProperty Step</a>
+ * @since 3.0.0-incubating
+ */
+ public default GraphTraversal<S, E> property(final Object value) {
Review comment:
I think this went to my earlier offline comment on why not provide more
specific data types. Based on that discussion I've updated this to be
`Map<Object, Object> ` as we cannot use a string for the key and use the `T`
enum.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]