@SuppressWarnings("unchecked")
    public static <T, K, U> Collector<T, ?, Map<K, U>> toUnmodifiableMap(
            Function<? super T, ? extends K> keyMapper,
            Function<? super T, ? extends U> valueMapper
    ) {
        return Collectors.collectingAndThen(
                Collectors.toMap(
                        Objects.requireNonNull(keyMapper, "keyMapper"),
                        Objects.requireNonNull(valueMapper, "valueMapper")),
                Collections::unmodifiableMap);
    }
Creates a collector that collects into an unmodifiable Map.

<p>This is a polyfill equivalent of Java 10's
{@code Collectors#toUnmodifiableMap}.

@param <T> the type to retrieve keys and values from.
@param <K> the Map's key type.
@param <U> the Map's value type.
@param keyMapper Function that retrieves the key.
@param valueMapper Function that retrieves the value.
@return a Collector that accumulates the entries into an unmodifiable Map.
smithy-utils/src/main/java/software/amazon/smithy/utils/MapUtils.java