protected static void validate(final Map map, final boolean ignoreTokens, final Set allowedTokens, final String op) {
        if (null == map) return;

        ((Map<?,?>) map).entrySet().forEach(e -> {
            final Object k = e.getKey();
            final Object v = e.getValue();

            if (ignoreTokens) {
                if (!(k instanceof String)) {
                    throw new IllegalArgumentException(String.format("option(onMatch) expects keys in Map to be of String - check: %s", k));
                } else {
                    ElementHelper.validateProperty((String) k, v);
                }
            } else {
                // don't allow null values for enums: T, Direction, Merge
                if (k instanceof Enum && v == null) {
                    throw new IllegalArgumentException(String.format("%s() does not allow null Map values - check: %s", op, k));
                }

                if (!(k instanceof String) && !allowedTokens.contains(k)) {
                    throw new IllegalArgumentException(String.format(
                            "%s() and option(onCreate) args expect keys in Map to be either String or %s - check: %s",
                            op, allowedTokens, k));
                }
                if (k == T.label) {
                    if (!(GValue.instanceOf(v, GType.STRING))) {
                        throw new IllegalArgumentException(String.format(
                                "%s() and option(onCreate) args expect T.label value to be of String - found: %s", op,
                                v.getClass().getSimpleName()));
                    } else {
                        ElementHelper.validateLabel((String) v);
                    }
                }
                if (k == Direction.OUT && v instanceof Merge && v != Merge.outV) {
                    throw new IllegalArgumentException(String.format("Only Merge.outV token may be used for Direction.OUT, found: %s", v));
                }
                if (k == Direction.IN && v instanceof Merge && v != Merge.inV) {
                    throw new IllegalArgumentException(String.format("Only Merge.inV token may be used for Direction.IN, found: %s", v));
                }
                if (k instanceof String) {
                    ElementHelper.validateProperty((String) k, v);
                }
            }
        });
    }
This implementation should only be used as a mechanism for supporting {@link PartitionStrategy}. Using this
with {@link GraphTraversal#with(String,Object)} will have an ill effect of simply acting like a call to
{@link GraphTraversal#property(Object, Object, Object...)}. No mutating steps currently support use of
{@link GraphTraversal#with(String,Object)} so perhaps it's best to not start with that now.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeElementStep.java