src/main/java/org/jmxtrans/agent/util/collect/Iterables2.java
@Nullable
    public static <T> T get(@Nonnull Iterable<T> iterable, @Nonnegative int position) throws NullPointerException, IndexOutOfBoundsException {
        if (iterable == null)
            throw new NullPointerException("iterable");

        if (iterable instanceof List) {
            return ((List<T>) iterable).get(position);
        }

        if (position < 0)
            throw new IndexOutOfBoundsException("Requested position must be greater than 0, '" + position + "' is invalid");

        int idx = 0;
        for (T value : iterable) {
            if (idx == position) {
                return value;
            }
            idx++;
        }
        throw new IndexOutOfBoundsException("Requested position must be smaller than iterable size (" + idx + "), '" + position + "' is invalid");
    }
@Nullable
    public static <T> T get(@Nonnull Iterable<T> iterable, @Nonnegative int position) throws NullPointerException, IndexOutOfBoundsException {
        if (iterable == null)
            throw new NullPointerException("iterable");

        if (iterable instanceof List) {
            return ((List<T>) iterable).get(position);
        }

        if (position < 0)
            throw new IndexOutOfBoundsException("Requested position must be greater than 0, '" + position + "' is invalid");

        int idx = 0;
        for (T value : iterable) {
            if (idx == position) {
                return value;
            }
            idx++;
        }
        throw new IndexOutOfBoundsException("Requested position must be smaller than iterable size (" + idx + "), '" + position + "' is invalid");
    }
Returns the element at the specified position in an iterable.

@param iterable the iterable to search into
@param position the position of the entry to return
@return the entry at the given <code>location</code> in the given <code>iterable</code>
throws
@throws IndexOutOfBoundsException if given {@code position} is negative or
greater than or equal to the size of given <code>iterable</code>