public static Type getGenericType(final Type type,
                                      final int paramNumber) {
        try {
            final ParameterizedType parameterizedType = ((ParameterizedType) type);
            return (parameterizedType.getActualTypeArguments().length < paramNumber)
                    ? Object.class
                    : parameterizedType.getActualTypeArguments()[paramNumber];
        } catch (Exception e) {
            return Object.class;
        }
    }
public static Type getGenericType ( final Type type , final int paramNumber ) { try { final ParameterizedType parameterizedType = ( ( ParameterizedType ) type ) ; return ( parameterizedType . getActualTypeArguments ( ) . length < paramNumber ) ? Object . class : parameterizedType . getActualTypeArguments ( ) [ paramNumber ] ; } catch ( Exception e ) { return Object . class ; } }
Extracts generic type

@param type to extract from
@param paramNumber actual param number in parameterized type array
@return actual type or object if length is not presented