@Test public void when_next_called_with_single_item_in_source_always_returns_same_item() { String item = UUID.randomUUID().toString(); List<String> source = new ArrayList<String>(); source.add(item); CircularList<String> list = new CircularList<String>(source); assertEquals(item, list.next()); assertEquals(item, list.next()); assertEquals(item, list.next()); }
public T next() { if(currentIndex == source.size()) currentIndex = 0; T value = source.get(currentIndex); currentIndex++; return value; }
CircularList { public T next() { if(currentIndex == source.size()) currentIndex = 0; T value = source.get(currentIndex); currentIndex++; return value; } }
CircularList { public T next() { if(currentIndex == source.size()) currentIndex = 0; T value = source.get(currentIndex); currentIndex++; return value; } CircularList(List<T> source); }
CircularList { public T next() { if(currentIndex == source.size()) currentIndex = 0; T value = source.get(currentIndex); currentIndex++; return value; } CircularList(List<T> source); T next(); }
CircularList { public T next() { if(currentIndex == source.size()) currentIndex = 0; T value = source.get(currentIndex); currentIndex++; return value; } CircularList(List<T> source); T next();  }