public static <K, V> void writeMap(
    @NotNull IonWriter writer,
    @NotNull String fieldName,
    @NotNull Map<K, V> map,
    @NotNull ThrowableConsumer<? super K, ? extends IOException> keyWriter,
    @NotNull ThrowableConsumer<? super V, ? extends IOException> valueWriter
  ) throws IOException {
    writer.setFieldName(fieldName);
    writer.stepIn(IonType.LIST);
    for (Map.Entry<K, V> entry : map.entrySet()) {
      writer.stepIn(IonType.STRUCT);
      writer.setFieldName(MAP_KEY_FIELD);
      keyWriter.consume(entry.getKey());
      writer.setFieldName(MAP_VALUE_FIELD);
      valueWriter.consume(entry.getValue());
      writer.stepOut();
    }
    writer.stepOut();
  }
public static <K, V> void writeMap(
    @NotNull IonWriter writer,
    @NotNull String fieldName,
    @NotNull Map<K, V> map,
    @NotNull ThrowableConsumer<? super K, ? extends IOException> keyWriter,
    @NotNull ThrowableConsumer<? super V, ? extends IOException> valueWriter
  )