/** * Helper method that can be used to dynamically figure out enumeration type of given {@link * EnumSet}, without having access to its declaration. Code is needed to work around design flaw * in JDK. * * @since 1.5 */ public static Class<? extends Enum<?>> findEnumType(EnumMap<?, ?> m) { if (!m.isEmpty()) { return findEnumType(m.keySet().iterator().next()); } // Otherwise need to locate using an internal field return EnumTypeLocator.instance.enumTypeFor(m); }