private static Class < ? > parameterizedReturnType ( Method method ) { Type type = method . getGenericReturnType ( ) ; if ( type instanceof ParameterizedType ) { try { return Class . forName ( ( ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) [ 0 ] ) . getTypeName ( ) ) ; } catch ( ClassNotFoundException e ) { return Object . class ; } } else { return Object . class ; } }
extract parameterized return value of a method .