@Test public void withScope() { final List<Genotype<DoubleGene>> genotypes1 = RandomRegistry.with(new Random(123), random -> Genotype.of(DoubleChromosome.of(0, 10)).instances() .limit(100) .collect(toList()) ); final List<Genotype<DoubleGene>> genotypes2 = RandomRegistry.with(new Random(123), random -> Genotype.of(DoubleChromosome.of(0, 10)).instances() .limit(100) .collect(toList()) ); assertEquals(genotypes1, genotypes2); }
public static <R extends Random, T> T with( final R random, final Function<? super R, ? extends T> function ) { return CONTEXT.with(() -> random, s -> function.apply(random)); }
RandomRegistry { public static <R extends Random, T> T with( final R random, final Function<? super R, ? extends T> function ) { return CONTEXT.with(() -> random, s -> function.apply(random)); } }
RandomRegistry { public static <R extends Random, T> T with( final R random, final Function<? super R, ? extends T> function ) { return CONTEXT.with(() -> random, s -> function.apply(random)); } private  RandomRegistry(); }
RandomRegistry { public static <R extends Random, T> T with( final R random, final Function<? super R, ? extends T> function ) { return CONTEXT.with(() -> random, s -> function.apply(random)); } private  RandomRegistry(); static Random random(); static void random(final Random random); static void random(final ThreadLocal<? extends Random> random); static void reset(); static void using(
		final R random,
		final Consumer<? super R> consumer
	); static void using(
		final ThreadLocal<R> random,
		final Consumer<? super R> consumer
	); static T with(
		final R random,
		final Function<? super R, ? extends T> function
	); static T with(
		final ThreadLocal<R> random,
		final Function<? super R, ? extends T> function
	); }
RandomRegistry { public static <R extends Random, T> T with( final R random, final Function<? super R, ? extends T> function ) { return CONTEXT.with(() -> random, s -> function.apply(random)); } private  RandomRegistry(); static Random random(); static void random(final Random random); static void random(final ThreadLocal<? extends Random> random); static void reset(); static void using(
		final R random,
		final Consumer<? super R> consumer
	); static void using(
		final ThreadLocal<R> random,
		final Consumer<? super R> consumer
	); static T with(
		final R random,
		final Function<? super R, ? extends T> function
	); static T with(
		final ThreadLocal<R> random,
		final Function<? super R, ? extends T> function
	);  }