@Nullable
  private static <E> Map<String, Map<String, String>> setToMap(
      @Nullable Set<E> set, Function<E, String> keyMapper) {
    if (set == null) {
      return null;
    }

    return set.stream()
        .collect(
            ImmutableSortedMap.toImmutableSortedMap(
                String::compareTo, keyMapper, ignored -> Collections.emptyMap()));
  }
Turns a set into a sorted map where each element of the set is mapped to an entry composed by
the key generated with {@code Function<E, String> elementMapper} and an empty map as value.

<p>This method is needed because the volume object is a direct JSON serialization of the Go
type map[string]struct{} and is represented in JSON as an object mapping its keys to an empty
object.

<p>Further read at the <a
href="https://github.com/opencontainers/image-spec/blob/master/config.md">image specs.</a>

@param set the set of elements to be transformed
@param keyMapper the mapper function to generate keys to the map
@param <E> the type of the elements from the set
@return an map
jib-core/src/main/java/com/google/cloud/tools/jib/image/json/ImageToJsonTranslator.java