static Object valueOf(final Class<?> type,final String str){
  if (!isValidEnum(type)) {
    return null;
  }
  try {
    final String valueOfMethod="valueOf";
    final Method m=type.getMethod(valueOfMethod,String.class);
    if (!Modifier.isStatic(m.getModifiers())) {
      return null;
    }
    final Class<?> returnType=m.getReturnType();
    if (!type.isAssignableFrom(returnType)) {
      return null;
    }
    return m.invoke(null,str);
  }
 catch (  final NoSuchMethodException|InvocationTargetException|IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}

static Object valueOf ( final Class < ? > type , final String str ) { if ( ! isValidEnum ( type ) ) { return null ; } try { final String valueOfMethod = "valueOf" ; final Method m = type . getMethod ( valueOfMethod , String . class ) ; if ( ! Modifier . isStatic ( m . getModifiers ( ) ) ) { return null ; } final Class < ? > returnType = m . getReturnType ( ) ; if ( ! type . isAssignableFrom ( returnType ) ) { return null ; } return m . invoke ( null , str ) ; } catch ( final NoSuchMethodException | InvocationTargetException | IllegalAccessException e ) { throw new RuntimeException ( e ) ; } }
gets the object specified by str .
