EnumeratingIterator implements Iterable<Enumerated<T>> { public static <T> EnumeratingIterator<T> of(Iterable<T> iterable) { return new EnumeratingIterator<>(iterable); } EnumeratingIterator(Iterable<T> iterable); static EnumeratingIterator<T> of(Iterable<T> iterable); @Override Iterator<Enumerated<T>> iterator();  }
@Test public void testOf() { List<Character> list = Arrays.asList('a', 'b', 'c', 'd'); int localCount = 0; for (Enumerated<Character> countingChar : EnumeratingIterator.of(list)) { int counted = countingChar.count(); assertEquals("count", localCount, counted); assertEquals("value", list.get(localCount), countingChar.get()); ++localCount; } }