@Test public void shouldAdvanceIteratorPastGivenElement() throws Exception { Iterator<Integer> advancedIterator = Utils.advancePast(ImmutableList.of(1, 2, 3, 4).iterator(), 2); ImmutableList<Integer> advancedList = ImmutableList.copyOf(advancedIterator); assertThat(advancedList).containsExactly(3, 4).inOrder(); }
static <T> Iterator<T> advancePast(@NonNull Iterator<T> iterator, @NonNull T element) { Preconditions.checkNotNull(iterator); Preconditions.checkNotNull(element); while (iterator.hasNext()) { if (iterator.next() == element) { break; } } Preconditions.checkArgument(iterator.hasNext()); return iterator; }
Utils { static <T> Iterator<T> advancePast(@NonNull Iterator<T> iterator, @NonNull T element) { Preconditions.checkNotNull(iterator); Preconditions.checkNotNull(element); while (iterator.hasNext()) { if (iterator.next() == element) { break; } } Preconditions.checkArgument(iterator.hasNext()); return iterator; } }
Utils { static <T> Iterator<T> advancePast(@NonNull Iterator<T> iterator, @NonNull T element) { Preconditions.checkNotNull(iterator); Preconditions.checkNotNull(element); while (iterator.hasNext()) { if (iterator.next() == element) { break; } } Preconditions.checkArgument(iterator.hasNext()); return iterator; } private  Utils(); }
Utils { static <T> Iterator<T> advancePast(@NonNull Iterator<T> iterator, @NonNull T element) { Preconditions.checkNotNull(iterator); Preconditions.checkNotNull(element); while (iterator.hasNext()) { if (iterator.next() == element) { break; } } Preconditions.checkArgument(iterator.hasNext()); return iterator; } private  Utils(); static ImmutableBiMap<Class<?>, String> buildClassToTableMap(ModelGraph<TModel> modelGraph); }
Utils { static <T> Iterator<T> advancePast(@NonNull Iterator<T> iterator, @NonNull T element) { Preconditions.checkNotNull(iterator); Preconditions.checkNotNull(element); while (iterator.hasNext()) { if (iterator.next() == element) { break; } } Preconditions.checkArgument(iterator.hasNext()); return iterator; } private  Utils(); static ImmutableBiMap<Class<?>, String> buildClassToTableMap(ModelGraph<TModel> modelGraph);  }