@Test(expected = NoSuchElementException.class) public void shouldThrowNoSuchElementWhenNoMoreItemsLeftAndNextCalled() throws Exception { final DelegatingPeekingKeyValueIterator<String, String> peekingIterator = new DelegatingPeekingKeyValueIterator<>(name, store.all()); peekingIterator.next(); }
@Override public synchronized KeyValue<K, V> next() { if (!hasNext()) { throw new NoSuchElementException(); } final KeyValue<K, V> result = next; next = null; return result; }
DelegatingPeekingKeyValueIterator implements KeyValueIterator<K, V>, PeekingKeyValueIterator<K, V> { @Override public synchronized KeyValue<K, V> next() { if (!hasNext()) { throw new NoSuchElementException(); } final KeyValue<K, V> result = next; next = null; return result; } }
DelegatingPeekingKeyValueIterator implements KeyValueIterator<K, V>, PeekingKeyValueIterator<K, V> { @Override public synchronized KeyValue<K, V> next() { if (!hasNext()) { throw new NoSuchElementException(); } final KeyValue<K, V> result = next; next = null; return result; } DelegatingPeekingKeyValueIterator(final String storeName, final KeyValueIterator<K, V> underlying); }
DelegatingPeekingKeyValueIterator implements KeyValueIterator<K, V>, PeekingKeyValueIterator<K, V> { @Override public synchronized KeyValue<K, V> next() { if (!hasNext()) { throw new NoSuchElementException(); } final KeyValue<K, V> result = next; next = null; return result; } DelegatingPeekingKeyValueIterator(final String storeName, final KeyValueIterator<K, V> underlying); @Override synchronized K peekNextKey(); @Override synchronized void close(); @Override synchronized boolean hasNext(); @Override synchronized KeyValue<K, V> next(); @Override void remove(); @Override KeyValue<K, V> peekNext(); }
DelegatingPeekingKeyValueIterator implements KeyValueIterator<K, V>, PeekingKeyValueIterator<K, V> { @Override public synchronized KeyValue<K, V> next() { if (!hasNext()) { throw new NoSuchElementException(); } final KeyValue<K, V> result = next; next = null; return result; } DelegatingPeekingKeyValueIterator(final String storeName, final KeyValueIterator<K, V> underlying); @Override synchronized K peekNextKey(); @Override synchronized void close(); @Override synchronized boolean hasNext(); @Override synchronized KeyValue<K, V> next(); @Override void remove(); @Override KeyValue<K, V> peekNext();  }