private static Class<?> findTargetComponentType(final Method method) {
        final Class<?> returnType = method.getReturnType();
        if (returnType.isArray()) {
            return method.getReturnType().getComponentType();
        }

        if (!(List.class.equals(returnType) || (Map.class.equals(returnType)) || XBAutoMap.class.isAssignableFrom(returnType) || XBAutoList.class.equals(returnType) || XBAutoValue.class.equals(returnType) || ReflectionHelper.isStreamClass(returnType))) {
            return null;
        }
        final Type type = method.getGenericReturnType();
        if (!(type instanceof ParameterizedType) || (((ParameterizedType) type).getActualTypeArguments() == null) || (((ParameterizedType) type).getActualTypeArguments().length < 1)) {
            throw new IllegalArgumentException("When using List as return type for method " + method + ", please specify a generic type for the List. Otherwise I do not know which type I should fill the List with.");
        }
        int index = Map.class.equals(returnType) ? 1 : 0;

        assert index < ((ParameterizedType) type).getActualTypeArguments().length;
        Type componentType = ((ParameterizedType) type).getActualTypeArguments()[index];
        if (!(componentType instanceof Class)) {
            throw new IllegalArgumentException("I don't know how to instantiate the generic type for the return type of method " + method);
        }
        return (Class<?>) componentType;
    }
private static Class < ? > findTargetComponentType ( final Method method ) { final Class < ? > returnType = method . getReturnType ( ) ; if ( returnType . isArray ( ) ) { return method . getReturnType ( ) . getComponentType ( ) ; } if ( ! ( List . class . equals ( returnType ) || ( Map . class . equals ( returnType ) ) || XBAutoMap . class . isAssignableFrom ( returnType ) || XBAutoList . class . equals ( returnType ) || XBAutoValue . class . equals ( returnType ) || ReflectionHelper . isStreamClass ( returnType ) ) ) { return null ; } final Type type = method . getGenericReturnType ( ) ; if ( ! ( type instanceof ParameterizedType ) || ( ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) == null ) || ( ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) . length < 1 ) ) { throw new IllegalArgumentException ( "When using List as return type for method " + method + ", please specify a generic type for the List. Otherwise I do not know which type I should fill the List with." ) ; } int index = Map . class . equals ( returnType ) ? 1 : 0 ; assert index < ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) . length ; Type componentType = ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) [ index ] ; if ( ! ( componentType instanceof Class ) ) { throw new IllegalArgumentException ( "I don't know how to instantiate the generic type for the return type of method " + method ) ; } return ( Class < ? > ) componentType ; }
When reading collections, determine the collection component type.

@param method
@return