guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java
public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf(
      Map<? extends Class<? extends S>, ? extends S> map) {
    if (map instanceof ImmutableClassToInstanceMap) {
      @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable)
      // Eclipse won't compile if we cast to the parameterized type.
      ImmutableClassToInstanceMap<B> cast = (ImmutableClassToInstanceMap) map;
      return cast;
    }
    return new Builder<B>().putAll(map).build();
  }
public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf(
      Map<? extends Class<? extends S>, ? extends S> map) {
    if (map instanceof ImmutableClassToInstanceMap) {
      @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable)
      // Eclipse won't compile if we cast to the parameterized type.
      ImmutableClassToInstanceMap<B> cast = (ImmutableClassToInstanceMap) map;
      return cast;
    }
    return new Builder<B>().putAll(map).build();
  }
Returns an immutable map containing the same entries as {@code map}. If {@code map} somehow
contains entries with duplicate keys (for example, if it is a {@code SortedMap} whose
comparator is not <i>consistent with equals</i>), the results of this method are undefined.

<p><b>Note:</b> Despite what the method name suggests, if {@code map} is an {@code
ImmutableClassToInstanceMap}, no copy will actually be performed.

@throws NullPointerException if any key or value in {@code map} is null
@throws ClassCastException if any value is not an instance of the type specified by its key