Iterable<Integer> (int row) { int maxRows = getRowCount(); return () -> new Iterator<>() { private int myRowIndex = Math.max(0, row - UP_PRELOAD_COUNT); @Override public boolean hasNext() { return myRowIndex < row + DOWN_PRELOAD_COUNT && myRowIndex < maxRows; } @Override public Integer next() { int nextRow = myRowIndex; myRowIndex++; return getIdAtRow(nextRow); } @Override public void remove() { throw new UnsupportedOperationException("Removing elements is not supported."); } }; }