| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public Collection<T> next() throws NoSuchElementException { |
| 89 | if (!hasNext()) { |
| 90 | throw new NoSuchElementException("No more pages through Asana API."); |
| 91 | } else if (ioException != null) { |
| 92 | // Wrapping an IOException in a NoSuchElementException is questionable practice, but the API has been this |
| 93 | // way since commit 23f13ec from 2015-04-03, so we leave the type for API backwards compatibility. |
| 94 | NoSuchElementException newException |
| 95 | = new NoSuchElementException("IOException when communicating through Asana API."); |
| 96 | newException.initCause(ioException); |
| 97 | throw newException; |
| 98 | } |
| 99 | |
| 100 | Collection<T> currentData = nextData; |
| 101 | nextData = null; |
| 102 | return currentData; |
| 103 | } |
| 104 | |
| 105 | @Override |
| 106 | public void remove() { |