Kelvin opened this one a while back:
https://issues.apache.org/jira/browse/TINKERPOP-2957
I'd like to suggest this syntax to resolve the issue of Cardinality
specification with mergeV():
// current approach to set cardinality
g.mergeV([firstname:"john",lastname:"handcock"]).
option(Merge.onMatch,sideEffect(property(single,"firstname","james"),
property(single,"lastname","madison")).constant([:]))
// current syntax will just use default cardinality for the underlying graph
g.mergeV(["firstname":"firstname"]).
option(Merge.onMatch, [firstname:"james",lastname:"madison"])
// revised syntax provide cardinality override per property where firstname
will be explicitly
// single but lastname will be the default for the underlying graph. the
`Cardinality.single()`
// a static method on Cardinality produces a CardinalityValue object which
will have
// special meaning to the MergeVStep
g.mergeV([firstname:"john",lastname:"handcock"]).
option(Merge.onMatch, [firstname:single("james"),lastname:"madison"])
// revised syntax to provide cardinality for all properties onMatch where
both firstname
// and lastname will be set explicitly to single
g.mergeV(["firstname":"firstname"]).
option(Merge.onMatch, [firstname:"james",lastname:"madison"], single)
// the above translates to the following so the user won't have to add
single to each property
g.mergeV([firstname:"john",lastname:"handcock"]).
option(Merge.onMatch,
[firstname:single("james"),lastname:single("madison")])