@Test public void when_next_called_with_two_items_in_source_items_are_returned_in_order() { String item1 = UUID.randomUUID().toString(); String item2 = UUID.randomUUID().toString(); List<String> source = new ArrayList<String>(); source.add(item1); source.add(item2); CircularList<String> list = new CircularList<String>(source); assertEquals(item1, list.next()); assertEquals(item2, 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();  }