code: @SuppressWarnings("unchecked")
       static <E> Set<E> dynamicallyCastSet(Set<?> set, 
                                                        Class<E> type) {
          return dynamicallyCastCollection(set, type, Set.class);
      }
docs: Dynamically check that the members of the set are all instances of
  the given type (or null).
  
  @param <E>
  the set's element type
  @param set
  the set to cast
  @param type
  the class of the set's element type.
  @return the dynamically-type checked set.
  @throws java.lang.ClassCastException