private String asString(final Map<?, ?> map) {
        final StringBuilder sb = new StringBuilder("[");
        int size = map.size();

        if (size == 0) {
            sb.append(":");
        } else {
            for (Map.Entry<?, ?> entry : map.entrySet()) {
                String key = argAsString(entry.getKey());
                // special handling for non-string keys
                if (entry.getKey() instanceof Enum && key.contains(".")) {
                    key = String.format("(%s)", key);
                }

                sb.append(key).append(":").append(argAsString(entry.getValue()));
                if (--size > 0) {
                    sb.append(',');
                }
            }
        }

        sb.append("]");
        return sb.toString();
    }
This class helps to build a gremlin-lang compatible string representation based on a {@link TraversalSource}
and then a {@link Traversal}.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLang.java