@Test public void cycleMinValueMaxValue() { final Supplier<Long> cycle = Suppliers.cycle(0, 3); assertThat(cycle.get(), is(0L)); assertThat(cycle.get(), is(1L)); assertThat(cycle.get(), is(2L)); assertThat(cycle.get(), is(3L)); assertThat(cycle.get(), is(0L)); assertThat(cycle.get(), is(1L)); }
public static <T> Supplier<T> cycle(final List<T> values) { final List<T> copy = ImmutableList.copyOf(values); checkArgument(!copy.isEmpty(), "values must not be empty"); final Iterator<T> it = Iterators.cycle(copy); return new Supplier<T>() { @Override public T get() { return it.next(); } @Override public String toString() { return String.format("cycle %s", copy); } }; }
Suppliers { public static <T> Supplier<T> cycle(final List<T> values) { final List<T> copy = ImmutableList.copyOf(values); checkArgument(!copy.isEmpty(), "values must not be empty"); final Iterator<T> it = Iterators.cycle(copy); return new Supplier<T>() { @Override public T get() { return it.next(); } @Override public String toString() { return String.format("cycle %s", copy); } }; } }
Suppliers { public static <T> Supplier<T> cycle(final List<T> values) { final List<T> copy = ImmutableList.copyOf(values); checkArgument(!copy.isEmpty(), "values must not be empty"); final Iterator<T> it = Iterators.cycle(copy); return new Supplier<T>() { @Override public T get() { return it.next(); } @Override public String toString() { return String.format("cycle %s", copy); } }; } private  Suppliers(); }
Suppliers { public static <T> Supplier<T> cycle(final List<T> values) { final List<T> copy = ImmutableList.copyOf(values); checkArgument(!copy.isEmpty(), "values must not be empty"); final Iterator<T> it = Iterators.cycle(copy); return new Supplier<T>() { @Override public T get() { return it.next(); } @Override public String toString() { return String.format("cycle %s", copy); } }; } private  Suppliers(); static Supplier<T> of(final T value); static Supplier<T> cycle(final List<T> values); static Supplier<Long> cycle(final long minValue, final long maxValue); static RandomSupplier.Builder<T> random(); static Supplier<Long> random(final long minValue, final long maxValue); }
Suppliers { public static <T> Supplier<T> cycle(final List<T> values) { final List<T> copy = ImmutableList.copyOf(values); checkArgument(!copy.isEmpty(), "values must not be empty"); final Iterator<T> it = Iterators.cycle(copy); return new Supplier<T>() { @Override public T get() { return it.next(); } @Override public String toString() { return String.format("cycle %s", copy); } }; } private  Suppliers(); static Supplier<T> of(final T value); static Supplier<T> cycle(final List<T> values); static Supplier<Long> cycle(final long minValue, final long maxValue); static RandomSupplier.Builder<T> random(); static Supplier<Long> random(final long minValue, final long maxValue);  }