@Override
        public Void mapShape(MapShape shape) {
            String entryName = nestedLevel > 0 ? "entry" + nestedLevel : "entry";
            writer.openBlock("$L.entrySet().stream()",
                    "",
                    varName,
                    () -> writer.write(".map($L -> new $T<>(", entryName, AbstractMap.SimpleImmutableEntry.class)
                            .indent()
                            .write("$C, $C))",
                                    (Runnable) () -> shape.getKey()
                                            .accept(new ToNodeMapperVisitor(
                                                    entryName + ".getKey()",
                                                    nestedLevel + 1)),
                                    (Runnable) () -> shape.getValue()
                                            .accept(new ToNodeMapperVisitor(
                                                    entryName + ".getValue()",
                                                    nestedLevel + 1)))
                            .dedent()
                            .write(".collect($1T.collect($2T::getKey, $2T::getValue))",
                                    ObjectNode.class,
                                    Map.Entry.class));
            return null;
        }
Determines how to map a shape to a node.
smithy-trait-codegen/src/main/java/software/amazon/smithy/traitcodegen/generators/ToNodeGenerator.java