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

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