private List getResultData()

in src/main/java/com/awslabs/resultsiterator/implementations/ResultsIteratorAbstract.java [186:208]


    private List<T> getResultData() {
        if (clientMethodReturningListT == null) {
            // Look for a public method that takes no arguments and returns a java.util.List<T>.  If zero or more than one exists, fail.
            // From: https://stackoverflow.com/a/1901275/796579
            Class<T> returnClass = Try.of(() -> (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0])
                    .orElse(Try.of(() -> (Class<T>) getClass().getGenericSuperclass()))
                    .getOrElse((Class<T>) java.util.List.class);
            clientMethodReturningListT = reflectionHelper.getMethodWithParameterAndReturnType(getResponseClass(), null, returnClass);
        }

        if (clientMethodReturningListT.isEmpty()) {
            throw new UnsupportedOperationException("Failed to find a method returning the expected list type, this should never happen.");
        }

        try {
            return List.ofAll((java.util.List<T>) clientMethodReturningListT.get().invoke(awsResponse));
        } catch (IllegalAccessException |
                InvocationTargetException e) {
            e.printStackTrace();
            throw new UnsupportedOperationException(e);
        }

    }