@Test public void shouldReturnFalseForHasNextIfAnEmptyIteratorIsSupplied() throws Exception { Iterable<Integer> input = iterableOf(Integer.class); CyclicIterator<Integer> iterator = new CyclicIterator<Integer>(input.iterator()); assertThat(iterator.hasNext(), is(false)); }
@Override public boolean hasNext() { if (shouldContinueCyclingInfinitely()) { return true; } if (shouldNotCycleAtAll()) { return false; } if (iteratorContainsMoreElements()) { return true; } if (!elementsAreCached()) { return false; } return hasRepeatsRemaining(); }
CyclicIterator implements Iterator<T> { @Override public boolean hasNext() { if (shouldContinueCyclingInfinitely()) { return true; } if (shouldNotCycleAtAll()) { return false; } if (iteratorContainsMoreElements()) { return true; } if (!elementsAreCached()) { return false; } return hasRepeatsRemaining(); } }
CyclicIterator implements Iterator<T> { @Override public boolean hasNext() { if (shouldContinueCyclingInfinitely()) { return true; } if (shouldNotCycleAtAll()) { return false; } if (iteratorContainsMoreElements()) { return true; } if (!elementsAreCached()) { return false; } return hasRepeatsRemaining(); } CyclicIterator(Iterator<? extends T> iterator);  CyclicIterator(Iterator<? extends T> iterator, int numberOfTimesToRepeat); }
CyclicIterator implements Iterator<T> { @Override public boolean hasNext() { if (shouldContinueCyclingInfinitely()) { return true; } if (shouldNotCycleAtAll()) { return false; } if (iteratorContainsMoreElements()) { return true; } if (!elementsAreCached()) { return false; } return hasRepeatsRemaining(); } CyclicIterator(Iterator<? extends T> iterator);  CyclicIterator(Iterator<? extends T> iterator, int numberOfTimesToRepeat); @Override boolean hasNext(); @Override T next(); @Override void remove(); @Override String toString(); }
CyclicIterator implements Iterator<T> { @Override public boolean hasNext() { if (shouldContinueCyclingInfinitely()) { return true; } if (shouldNotCycleAtAll()) { return false; } if (iteratorContainsMoreElements()) { return true; } if (!elementsAreCached()) { return false; } return hasRepeatsRemaining(); } CyclicIterator(Iterator<? extends T> iterator);  CyclicIterator(Iterator<? extends T> iterator, int numberOfTimesToRepeat); @Override boolean hasNext(); @Override T next(); @Override void remove(); @Override String toString();  }