@SuppressWarnings("unchecked") public static Class<? extends Enum<?>> findEnumType(Class<?> cls){
  if (cls.getSuperclass() != Enum.class) {
    cls=cls.getSuperclass();
  }
  return (Class<? extends Enum<?>>)cls;
}

@ SuppressWarnings ( "unchecked" ) public static Class < ? extends Enum < ? > > findEnumType ( Class < ? > cls ) { if ( cls . getSuperclass ( ) != Enum . class ) { cls = cls . getSuperclass ( ) ; } return ( Class < ? extends Enum < ? > > ) cls ; }
helper method that can be used to dynamically figure out formal enumeration type ( class ) for given class of an enumeration value . this is either class of enum instance ( for " simple " enumerations ) , or its superclass ( for enums with instance fields or methods )
